{"version":3,"file":"snapshot.cjs","names":["params: Record<string, string>"],"sources":["../../../../src/rest/commands/schema/snapshot.ts"],"sourcesContent":["import type { AllCollections } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\n\n// TODO improve typing\nexport type SchemaSnapshotOutput = {\n\t/** `1` for a full snapshot, `2` for a partial (collection-scoped) snapshot. */\n\tversion: number;\n\tdirectus: string;\n\tvendor: string;\n\tcollections: Record<string, any>[];\n\tfields: Record<string, any>[];\n\tsystemFields: Record<string, any>[];\n\trelations: Record<string, any>[];\n};\n\n/**\n * Optional collection scoping for {@link schemaSnapshot}. Omit for a full snapshot, or provide exactly one of\n * `includeCollections` / `excludeCollections` for a partial snapshot.\n */\nexport type SchemaSnapshotOptions<Schema> =\n\t| {\n\t\t\t/**\n\t\t\t * Restrict the snapshot to these collections (partial snapshot). Mutually exclusive with `excludeCollections`.\n\t\t\t */\n\t\t\tincludeCollections: AllCollections<Schema>[];\n\t  }\n\t| {\n\t\t\t/**\n\t\t\t * Exclude these collections from the snapshot (partial snapshot). Mutually exclusive with `includeCollections`.\n\t\t\t */\n\t\t\texcludeCollections: AllCollections<Schema>[];\n\t  };\n\n/**\n * Retrieve the current schema. This endpoint is only available to admin users.\n *\n * @param options Optional collection scoping (partial). Omit for a full snapshot.\n * @param options.includeCollections Restrict the snapshot to these collections.\n * @param options.excludeCollections Exclude these collections from the snapshot.\n *\n * @returns Returns the JSON object containing schema details.\n * @throws Will throw if both `includeCollections` and `excludeCollections` are provided.\n */\nexport const schemaSnapshot =\n\t<Schema>(options?: SchemaSnapshotOptions<Schema>): RestCommand<SchemaSnapshotOutput, Schema> =>\n\t() => {\n\t\tconst includeCollections = options && 'includeCollections' in options;\n\t\tconst excludeCollections = options && 'excludeCollections' in options;\n\n\t\tif (includeCollections && excludeCollections) {\n\t\t\tthrow new Error(`\"includeCollections\" and \"excludeCollections\" parameters cannot be used together`);\n\t\t}\n\n\t\tconst params: Record<string, string> = {};\n\n\t\tif (includeCollections) params['includeCollections'] = options.includeCollections.join(',');\n\t\tif (excludeCollections) params['excludeCollections'] = options.excludeCollections.join(',');\n\n\t\treturn {\n\t\t\tmethod: 'GET',\n\t\t\tpath: '/schema/snapshot',\n\t\t\tparams,\n\t\t};\n\t};\n"],"mappings":"AA2CA,MAAa,EACH,OACH,CACL,IAAM,EAAqB,GAAW,uBAAwB,EACxD,EAAqB,GAAW,uBAAwB,EAE9D,GAAI,GAAsB,EACzB,MAAU,MAAM,mFAAmF,CAGpG,IAAMA,EAAiC,EAAE,CAKzC,OAHI,IAAoB,EAAO,mBAAwB,EAAQ,mBAAmB,KAAK,IAAI,EACvF,IAAoB,EAAO,mBAAwB,EAAQ,mBAAmB,KAAK,IAAI,EAEpF,CACN,OAAQ,MACR,KAAM,mBACN,SACA"}