Neues Appwrite-Feld subscriptions.productKey (Setup-Skript). Ohne bekannten Abo-Preis gilt ein Abo weiter als Wartungs-Abo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 lines
720 B
JavaScript
15 lines
720 B
JavaScript
import { readFileSync } from 'node:fs'
|
|
|
|
/**
|
|
* Attribut-Schlüssel einer Collection, wie sie scripts/setup-abo-collections.mjs in Appwrite
|
|
* anlegt. Tests geben sie dem Appwrite-Nachbau als Schema: Schreibt der Code ein Feld, das das
|
|
* Setup-Skript nicht anlegt, scheitert der Test wie Appwrite in Produktion.
|
|
*/
|
|
export function schemaKeys(collection) {
|
|
const src = readFileSync(new URL('../../scripts/setup-abo-collections.mjs', import.meta.url), 'utf8')
|
|
const start = src.indexOf(`'${collection}',`)
|
|
if (start < 0) throw new Error(`Collection ${collection} fehlt im Setup-Skript`)
|
|
const block = src.slice(start, src.indexOf('\n ],', start))
|
|
return [...block.matchAll(/key: '(\w+)'/g)].map((m) => m[1])
|
|
}
|