prismic-ts-codegen 0.1.30-pr.82.96148f3 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cli/configSchema.d.mts +4 -2
  2. package/dist/cli/configSchema.d.mts.map +1 -1
  3. package/dist/cli/configSchema.mjs +2 -126
  4. package/dist/cli/configSchema.mjs.map +1 -1
  5. package/dist/cli/constants.d.mts +2 -1
  6. package/dist/cli/constants.d.mts.map +1 -1
  7. package/dist/cli/loadConfig.mjs +9 -9
  8. package/dist/cli/loadConfig.mjs.map +1 -1
  9. package/dist/cli/loadLocaleIDs.mjs +1 -0
  10. package/dist/cli/loadLocaleIDs.mjs.map +1 -1
  11. package/dist/cli/loadModels.mjs +10 -13
  12. package/dist/cli/loadModels.mjs.map +1 -1
  13. package/dist/cli.d.mts +1 -1
  14. package/dist/cli.mjs +16 -41
  15. package/dist/cli.mjs.map +1 -1
  16. package/dist/constants.mjs.map +1 -1
  17. package/dist/detectTypesProvider.d.mts +4 -2
  18. package/dist/detectTypesProvider.d.mts.map +1 -1
  19. package/dist/detectTypesProvider.mjs.map +1 -1
  20. package/dist/generateTypes.d.mts +5 -3
  21. package/dist/generateTypes.d.mts.map +1 -1
  22. package/dist/generateTypes.mjs +12 -15
  23. package/dist/generateTypes.mjs.map +1 -1
  24. package/dist/lib/addBlankLine.mjs.map +1 -1
  25. package/dist/lib/addLine.mjs.map +1 -1
  26. package/dist/lib/addSection.mjs.map +1 -1
  27. package/dist/lib/addTrailingNewLine.mjs.map +1 -1
  28. package/dist/lib/buildCustomTypeDataType.mjs +2 -2
  29. package/dist/lib/buildCustomTypeDataType.mjs.map +1 -1
  30. package/dist/lib/buildCustomTypeType.mjs +2 -2
  31. package/dist/lib/buildCustomTypeType.mjs.map +1 -1
  32. package/dist/lib/buildFieldDocs.mjs +4 -9
  33. package/dist/lib/buildFieldDocs.mjs.map +1 -1
  34. package/dist/lib/buildFieldProperties.mjs +14 -18
  35. package/dist/lib/buildFieldProperties.mjs.map +1 -1
  36. package/dist/lib/buildSharedSliceType.mjs +10 -10
  37. package/dist/lib/buildSharedSliceType.mjs.map +1 -1
  38. package/dist/lib/buildTypeName.mjs +2 -2
  39. package/dist/lib/buildTypeName.mjs.map +1 -1
  40. package/dist/lib/buildUnion.mjs.map +1 -1
  41. package/dist/lib/checkHasUIDFIeld.mjs.map +1 -1
  42. package/dist/lib/getAPIIDPath.mjs.map +1 -1
  43. package/dist/lib/getCacheKey.mjs.map +1 -1
  44. package/dist/lib/getHumanReadableModelName.mjs.map +1 -1
  45. package/dist/lib/getHumanReadablePath.mjs.map +1 -1
  46. package/dist/types.d.mts +3 -1
  47. package/dist/types.d.mts.map +1 -1
  48. package/package.json +22 -18
  49. package/src/cli/index.ts +22 -38
  50. package/src/cli/loadConfig.ts +9 -7
  51. package/src/cli/loadLocaleIDs.ts +1 -0
  52. package/src/cli/loadModels.ts +12 -30
  53. package/src/generateTypes.ts +3 -3
  54. package/src/lib/buildCustomTypeDataType.ts +2 -2
  55. package/src/lib/buildCustomTypeType.ts +6 -6
  56. package/src/lib/buildFieldProperties.ts +7 -7
  57. package/src/lib/buildSharedSliceType.ts +33 -22
  58. package/src/lib/buildTypeName.ts +4 -9
  59. package/dist/lib/dedent.mjs +0 -12
  60. package/dist/lib/dedent.mjs.map +0 -1
  61. package/dist/package.mjs +0 -7
  62. package/dist/package.mjs.map +0 -1
  63. package/src/lib/dedent.ts +0 -14
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
+
2
3
  //#region src/cli/configSchema.d.ts
3
4
  /** Configuration to control the generated types. */
4
- export declare const configSchema: z.ZodObject<{
5
+ declare const configSchema: z.ZodObject<{
5
6
  repositoryName: z.ZodOptional<z.ZodString>;
6
7
  accessToken: z.ZodOptional<z.ZodString>;
7
8
  customTypesAPIToken: z.ZodOptional<z.ZodString>;
@@ -32,6 +33,7 @@ export declare const configSchema: z.ZodObject<{
32
33
  }, z.core.$strip>>;
33
34
  }, z.core.$strip>;
34
35
  /** Configuration to control the generated types. */
35
- export type Config = z.infer<typeof configSchema>;
36
+ type Config = z.infer<typeof configSchema>;
36
37
  //#endregion
38
+ export { Config };
37
39
  //# sourceMappingURL=configSchema.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configSchema.d.mts","names":[],"sources":["../../src/cli/configSchema.ts"],"mappings":";;;qBAGa,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkLvB,EAAA,KAAA;;YAGU,SAAS,EAAE,aAAa"}
1
+ {"version":3,"file":"configSchema.d.mts","names":[],"sources":["../../src/cli/configSchema.ts"],"mappings":";;;;cAGa,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqLb,MAAA,GAAS,CAAA,CAAE,KAAA,QAAa,YAAA"}
@@ -2,150 +2,26 @@ import { z } from "zod";
2
2
  //#region src/cli/configSchema.ts
3
3
  /** Configuration to control the generated types. */
4
4
  const configSchema = z.object({
5
- /** The name of the Prismic repository. */
6
5
  repositoryName: z.string().optional(),
7
- /**
8
- * The access token for the Prismic repository. If the repository is private and
9
- * `locales.fetchFromRepository` is `true`, providing a token is required.
10
- */
11
6
  accessToken: z.string().optional(),
12
- /**
13
- * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is
14
- * `true`, providing a token is required.
15
- */
16
7
  customTypesAPIToken: z.string().optional(),
17
- /**
18
- * The file path where the generated types will be saved. This path is relative to where the
19
- * command is called.
20
- */
21
8
  output: z.string().optional(),
22
- /**
23
- * The package that provides TypeScript types for Prismic data. Most projects will not need to
24
- * configure this option.
25
- *
26
- * @defaultValue Automatically detected using the project's `package.json`.
27
- */
28
9
  typesProvider: z.enum(["@prismicio/client", "@prismicio/types"]).optional(),
29
- /** Configuration for automatic `@prismicio/client` integration. */
30
10
  clientIntegration: z.object({
31
- /**
32
- * Determines if a `@prismicio/client` integration with automatic typing should be included in
33
- * the output.
34
- *
35
- * If set to `true`, Prismic clients will automatically be typed with the generated Custom
36
- * Types and Slices.
37
- *
38
- * **Note**: If your project queries content from multiple Prismic repositories, set
39
- * `includeCreateClientInterface` to `true` for the primary repository and `false` or any
40
- * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be
41
- * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to
42
- * type the client.
43
- *
44
- * @defaultValue `true`
45
- */
46
11
  includeCreateClientInterface: z.boolean().optional(),
47
- /**
48
- * Determines if a `@prismicio/client` namespace named `Content` containing all Document and
49
- * Slice types should be included in the output.
50
- *
51
- * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to
52
- * import to easily access types for your Prismic repository content.
53
- *
54
- * **Note**: If your project queries content from multiple Prismic repositories, set
55
- * `includeContentNamespace` to `true` for the primary repository and `false` or any other
56
- * repository. Types for non-primary repositories should be imported directly from the
57
- * generated file rather than via the `Content` namespace.
58
- *
59
- * @defaultValue `true`
60
- */
61
12
  includeContentNamespace: z.boolean().optional()
62
13
  }).optional(),
63
- /**
64
- * Configuration for languages for the Prismic repository.
65
- *
66
- * It can be configured by providing an array of locale IDs configured for the repository or an
67
- * object with finer control.
68
- *
69
- * @example
70
- * ```ts
71
- * ["en-us", "fr-fr"];
72
- * ```;
73
- *
74
- * @example
75
- * ```ts
76
- * {
77
- * "ids": ["en-us", "fr-fr"],
78
- * "fetchFromRepository": true
79
- * }
80
- * ```;
81
- */
82
14
  locales: z.union([z.array(z.string()), z.object({
83
- /**
84
- * A list of locales configured for the Prismic repository. This is used to type a
85
- * document's `lang` property.
86
- *
87
- * @example
88
- * ```ts
89
- * ["en-us", "fr-fr"];
90
- * ```;
91
- */
92
15
  ids: z.array(z.string()).optional(),
93
- /**
94
- * Determines if the Prismic repository's locales should be fetched from the repository's
95
- * API.
96
- */
97
16
  fetchFromRepository: z.boolean().optional()
98
17
  })]).optional(),
99
- /**
100
- * Configuration for Custom Type and Slice models for the Prismic repository.
101
- *
102
- * It can be configured by providing an array of file paths to Custom Type and Slice JSON models
103
- * or an object with finer control.
104
- */
105
18
  models: z.union([z.array(z.string()), z.object({
106
- /** A list of file paths to Custom Type and Slice models. Globs are supported. */
107
19
  files: z.array(z.string()).optional(),
108
- /**
109
- * Determines if the Prismic repository's Custom Type and Slice models should be fetched
110
- * from the repository's API.
111
- *
112
- * `customTypesAPIToken` must be provided if set to `true`.
113
- */
114
20
  fetchFromRepository: z.boolean().optional()
115
21
  })]).optional(),
116
- /** Configuration for types generated for fields. */
117
22
  fields: z.object({
118
- /** Configuration for Embed fields. */
119
- embed: z.object({
120
- /**
121
- * An object mapping oEmbed providers to their type. The type should be provided as a
122
- * string and is added directly into the generated types.
123
- *
124
- * @example
125
- * ```ts
126
- * {
127
- * "YouTube": "import('./types').OEmbedYouTube"
128
- * "Twitter": "import('./types').OEmbedTwitter"
129
- * "Vimeo": "import('./types').OEmbedVimeo"
130
- * }
131
- * ```;
132
- */
133
- providerTypes: z.record(z.string(), z.string()).optional() }).optional(),
134
- /** Configuration for Integration Fields. */
135
- integrationFields: z.object({
136
- /**
137
- * An object mapping catalog IDs to their type. The type should be provided as a string
138
- * and is added directly into the generated types.
139
- *
140
- * @example
141
- * ```ts
142
- * {
143
- * "shopify_products": "import('./types').IntegrationFieldShopifyProduct"
144
- * "mux_videos": "import('./types').IntegrationFieldMuxVideo"
145
- * }
146
- * ```;
147
- */
148
- catalogTypes: z.record(z.string(), z.string()).optional() }).optional()
23
+ embed: z.object({ providerTypes: z.record(z.string(), z.string()).optional() }).optional(),
24
+ integrationFields: z.object({ catalogTypes: z.record(z.string(), z.string()).optional() }).optional()
149
25
  }).optional()
150
26
  });
151
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"configSchema.mjs","names":[],"sources":["../../src/cli/configSchema.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Configuration to control the generated types. */\nexport const configSchema = z.object({\n\t/** The name of the Prismic repository. */\n\trepositoryName: z.string().optional(),\n\n\t/**\n\t * The access token for the Prismic repository. If the repository is private and\n\t * `locales.fetchFromRepository` is `true`, providing a token is required.\n\t */\n\taccessToken: z.string().optional(),\n\n\t/**\n\t * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is\n\t * `true`, providing a token is required.\n\t */\n\tcustomTypesAPIToken: z.string().optional(),\n\n\t/**\n\t * The file path where the generated types will be saved. This path is relative to where the\n\t * command is called.\n\t */\n\toutput: z.string().optional(),\n\n\t/**\n\t * The package that provides TypeScript types for Prismic data. Most projects will not need to\n\t * configure this option.\n\t *\n\t * @defaultValue Automatically detected using the project's `package.json`.\n\t */\n\ttypesProvider: z.enum([\"@prismicio/client\", \"@prismicio/types\"]).optional(),\n\n\t/** Configuration for automatic `@prismicio/client` integration. */\n\tclientIntegration: z\n\t\t.object({\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` integration with automatic typing should be included in\n\t\t\t * the output.\n\t\t\t *\n\t\t\t * If set to `true`, Prismic clients will automatically be typed with the generated Custom\n\t\t\t * Types and Slices.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeCreateClientInterface` to `true` for the primary repository and `false` or any\n\t\t\t * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be\n\t\t\t * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to\n\t\t\t * type the client.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeCreateClientInterface: z.boolean().optional(),\n\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` namespace named `Content` containing all Document and\n\t\t\t * Slice types should be included in the output.\n\t\t\t *\n\t\t\t * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to\n\t\t\t * import to easily access types for your Prismic repository content.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeContentNamespace` to `true` for the primary repository and `false` or any other\n\t\t\t * repository. Types for non-primary repositories should be imported directly from the\n\t\t\t * generated file rather than via the `Content` namespace.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeContentNamespace: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\n\t/**\n\t * Configuration for languages for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of locale IDs configured for the repository or an\n\t * object with finer control.\n\t *\n\t * @example\n\t * \t```ts\n\t * \t[\"en-us\", \"fr-fr\"];\n\t * \t```;\n\t *\n\t * @example\n\t * \t```ts\n\t * \t{\n\t * \t\"ids\": [\"en-us\", \"fr-fr\"],\n\t * \t\"fetchFromRepository\": true\n\t * \t}\n\t * \t```;\n\t */\n\tlocales: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/**\n\t\t\t\t * A list of locales configured for the Prismic repository. This is used to type a\n\t\t\t\t * document's `lang` property.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t * \t```ts\n\t\t\t\t * \t[\"en-us\", \"fr-fr\"];\n\t\t\t\t * \t```;\n\t\t\t\t */\n\t\t\t\tids: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's locales should be fetched from the repository's\n\t\t\t\t * API.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/**\n\t * Configuration for Custom Type and Slice models for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of file paths to Custom Type and Slice JSON models\n\t * or an object with finer control.\n\t */\n\tmodels: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/** A list of file paths to Custom Type and Slice models. Globs are supported. */\n\t\t\t\tfiles: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's Custom Type and Slice models should be fetched\n\t\t\t\t * from the repository's API.\n\t\t\t\t *\n\t\t\t\t * `customTypesAPIToken` must be provided if set to `true`.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/** Configuration for types generated for fields. */\n\tfields: z\n\t\t.object({\n\t\t\t/** Configuration for Embed fields. */\n\t\t\tembed: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping oEmbed providers to their type. The type should be provided as a\n\t\t\t\t\t * string and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"YouTube\": \"import('./types').OEmbedYouTube\"\n\t\t\t\t\t * \t\"Twitter\": \"import('./types').OEmbedTwitter\"\n\t\t\t\t\t * \t\"Vimeo\": \"import('./types').OEmbedVimeo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tproviderTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\n\t\t\t/** Configuration for Integration Fields. */\n\t\t\tintegrationFields: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping catalog IDs to their type. The type should be provided as a string\n\t\t\t\t\t * and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"shopify_products\": \"import('./types').IntegrationFieldShopifyProduct\"\n\t\t\t\t\t * \t\"mux_videos\": \"import('./types').IntegrationFieldMuxVideo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tcatalogTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/** Configuration to control the generated types. */\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAGA,MAAa,eAAe,EAAE,OAAO;;CAEpC,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;CAMpC,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;CAMjC,qBAAqB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;CAMzC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;;;CAQ5B,eAAe,EAAE,KAAK,CAAC,qBAAqB,kBAAkB,CAAC,CAAC,CAAC,SAAS;;CAG1E,mBAAmB,EACjB,OAAO;;;;;;;;;;;;;;;;EAgBP,8BAA8B,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;;;;;;;;;;EAgBnD,yBAAyB,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC/C,CAAC,CAAC,CACD,SAAS;;;;;;;;;;;;;;;;;;;;CAqBX,SAAS,EACP,MAAM,CACN,EAAE,MAAM,EAAE,OAAO,CAAC,GAClB,EAAE,OAAO;;;;;;;;;;EAUR,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;;;;;EAMlC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC3C,CAAC,CACF,CAAC,CAAC,CACD,SAAS;;;;;;;CAQX,QAAQ,EACN,MAAM,CACN,EAAE,MAAM,EAAE,OAAO,CAAC,GAClB,EAAE,OAAO;;EAER,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;;;;;;;EAQpC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC3C,CAAC,CACF,CAAC,CAAC,CACD,SAAS;;CAGX,QAAQ,EACN,OAAO;;EAEP,OAAO,EACL,OAAO;;;;;;;;;;;;;;AAcP,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EAC1D,CAAC,CAAC,CACD,SAAS;;EAGX,mBAAmB,EACjB,OAAO;;;;;;;;;;;;;AAaP,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EACzD,CAAC,CAAC,CACD,SAAS;CACZ,CAAC,CAAC,CACD,SAAS;AACZ,CAAC"}
1
+ {"version":3,"file":"configSchema.mjs","names":[],"sources":["../../src/cli/configSchema.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Configuration to control the generated types. */\nexport const configSchema = z.object({\n\t/** The name of the Prismic repository. */\n\trepositoryName: z.string().optional(),\n\n\t/**\n\t * The access token for the Prismic repository. If the repository is private and\n\t * `locales.fetchFromRepository` is `true`, providing a token is required.\n\t */\n\taccessToken: z.string().optional(),\n\n\t/**\n\t * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is\n\t * `true`, providing a token is required.\n\t */\n\tcustomTypesAPIToken: z.string().optional(),\n\n\t/**\n\t * The file path where the generated types will be saved. This path is relative to where the\n\t * command is called.\n\t */\n\toutput: z.string().optional(),\n\n\t/**\n\t * The package that provides TypeScript types for Prismic data. Most projects will not need to\n\t * configure this option.\n\t *\n\t * @defaultValue Automatically detected using the project's `package.json`.\n\t */\n\ttypesProvider: z.enum([\"@prismicio/client\", \"@prismicio/types\"]).optional(),\n\n\t/** Configuration for automatic `@prismicio/client` integration. */\n\tclientIntegration: z\n\t\t.object({\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` integration with automatic typing should be included in\n\t\t\t * the output.\n\t\t\t *\n\t\t\t * If set to `true`, Prismic clients will automatically be typed with the generated Custom\n\t\t\t * Types and Slices.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeCreateClientInterface` to `true` for the primary repository and `false` or any\n\t\t\t * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be\n\t\t\t * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to\n\t\t\t * type the client.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeCreateClientInterface: z.boolean().optional(),\n\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` namespace named `Content` containing all Document and\n\t\t\t * Slice types should be included in the output.\n\t\t\t *\n\t\t\t * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to\n\t\t\t * import to easily access types for your Prismic repository content.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeContentNamespace` to `true` for the primary repository and `false` or any other\n\t\t\t * repository. Types for non-primary repositories should be imported directly from the\n\t\t\t * generated file rather than via the `Content` namespace.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeContentNamespace: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\n\t/**\n\t * Configuration for languages for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of locale IDs configured for the repository or an\n\t * object with finer control.\n\t *\n\t * @example\n\t * \t```ts\n\t * \t[\"en-us\", \"fr-fr\"];\n\t * \t```;\n\t *\n\t * @example\n\t * \t```ts\n\t * \t{\n\t * \t\"ids\": [\"en-us\", \"fr-fr\"],\n\t * \t\"fetchFromRepository\": true\n\t * \t}\n\t * \t```;\n\t */\n\tlocales: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/**\n\t\t\t\t * A list of locales configured for the Prismic repository. This is used to type a\n\t\t\t\t * document's `lang` property.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t * \t```ts\n\t\t\t\t * \t[\"en-us\", \"fr-fr\"];\n\t\t\t\t * \t```;\n\t\t\t\t */\n\t\t\t\tids: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's locales should be fetched from the repository's\n\t\t\t\t * API.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/**\n\t * Configuration for Custom Type and Slice models for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of file paths to Custom Type and Slice JSON models\n\t * or an object with finer control.\n\t */\n\tmodels: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/** A list of file paths to Custom Type and Slice models. Globs are supported. */\n\t\t\t\tfiles: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's Custom Type and Slice models should be fetched\n\t\t\t\t * from the repository's API.\n\t\t\t\t *\n\t\t\t\t * `customTypesAPIToken` must be provided if set to `true`.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/** Configuration for types generated for fields. */\n\tfields: z\n\t\t.object({\n\t\t\t/** Configuration for Embed fields. */\n\t\t\tembed: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping oEmbed providers to their type. The type should be provided as a\n\t\t\t\t\t * string and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"YouTube\": \"import('./types').OEmbedYouTube\"\n\t\t\t\t\t * \t\"Twitter\": \"import('./types').OEmbedTwitter\"\n\t\t\t\t\t * \t\"Vimeo\": \"import('./types').OEmbedVimeo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tproviderTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\n\t\t\t/** Configuration for Integration Fields. */\n\t\t\tintegrationFields: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping catalog IDs to their type. The type should be provided as a string\n\t\t\t\t\t * and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"shopify_products\": \"import('./types').IntegrationFieldShopifyProduct\"\n\t\t\t\t\t * \t\"mux_videos\": \"import('./types').IntegrationFieldMuxVideo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tcatalogTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/** Configuration to control the generated types. */\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAGA,MAAa,eAAe,EAAE,OAAO;CAEpC,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CAMrC,aAAa,EAAE,QAAQ,CAAC,UAAU;CAMlC,qBAAqB,EAAE,QAAQ,CAAC,UAAU;CAM1C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAQ7B,eAAe,EAAE,KAAK,CAAC,qBAAqB,mBAAmB,CAAC,CAAC,UAAU;CAG3E,mBAAmB,EACjB,OAAO;EAgBP,8BAA8B,EAAE,SAAS,CAAC,UAAU;EAgBpD,yBAAyB,EAAE,SAAS,CAAC,UAAU;EAC/C,CAAC,CACD,UAAU;CAqBZ,SAAS,EACP,MAAM,CACN,EAAE,MAAM,EAAE,QAAQ,CAAC,EACnB,EAAE,OAAO;EAUR,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAMnC,qBAAqB,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAQZ,QAAQ,EACN,MAAM,CACN,EAAE,MAAM,EAAE,QAAQ,CAAC,EACnB,EAAE,OAAO;EAER,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAQrC,qBAAqB,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAGZ,QAAQ,EACN,OAAO;EAEP,OAAO,EACL,OAAO,EAcP,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU,EAC1D,CAAC,CACD,UAAU;EAGZ,mBAAmB,EACjB,OAAO,EAaP,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU,EACzD,CAAC,CACD,UAAU;EACZ,CAAC,CACD,UAAU;CACZ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  //#region src/cli/constants.d.ts
2
- export declare const NON_EDITABLE_FILE_HEADER = "// Code generated by prismic-ts-codegen. DO NOT EDIT.";
2
+ declare const NON_EDITABLE_FILE_HEADER = "// Code generated by prismic-ts-codegen. DO NOT EDIT.";
3
3
  //#endregion
4
+ export { NON_EDITABLE_FILE_HEADER };
4
5
  //# sourceMappingURL=constants.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/cli/constants.ts"],"mappings":";qBAAa"}
1
+ {"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/cli/constants.ts"],"mappings":";cAAa,wBAAA"}
@@ -1,17 +1,17 @@
1
1
  import { existsSync } from "fs";
2
2
  import { resolve } from "path";
3
- import { createJiti } from "jiti";
3
+ import _jiti from "jiti";
4
4
  //#region src/cli/loadConfig.ts
5
- const jiti = createJiti(process.cwd());
6
- const loadModuleWithJiti = async (id) => {
7
- return await jiti.import(id, { default: true });
5
+ const jiti = _jiti(process.cwd());
6
+ const loadModuleWithJiti = (id) => {
7
+ const mod = jiti(id);
8
+ return typeof mod === "object" && mod !== null && "default" in mod ? mod.default : mod;
8
9
  };
9
10
  const DEFAULT_CONFIG_PATHS = ["prismicCodegen.config.ts", "prismicCodegen.config.js"];
10
- const loadConfig = async (config) => {
11
- if (config.path) {
12
- if (existsSync(config.path)) return await loadModuleWithJiti(resolve(config.path));
13
- else throw new Error(`Config file does not exist: ${config.path}`);
14
- } else for (const configPath of DEFAULT_CONFIG_PATHS) if (existsSync(configPath)) return await loadModuleWithJiti(resolve(configPath));
11
+ const loadConfig = (config) => {
12
+ if (config.path) if (existsSync(config.path)) return loadModuleWithJiti(resolve(config.path));
13
+ else throw new Error(`Config file does not exist: ${config.path}`);
14
+ else for (const configPath of DEFAULT_CONFIG_PATHS) if (existsSync(configPath)) return loadModuleWithJiti(resolve(configPath));
15
15
  return {};
16
16
  };
17
17
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"loadConfig.mjs","names":["resolvePath"],"sources":["../../src/cli/loadConfig.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { createJiti } from \"jiti\";\n\nimport type { Config } from \"./configSchema\";\n\nconst jiti = createJiti(process.cwd());\n\nconst loadModuleWithJiti = async <TModule>(id: string): Promise<TModule> => {\n\treturn await jiti.import<TModule>(id, { default: true });\n};\n\nconst DEFAULT_CONFIG_PATHS = [\"prismicCodegen.config.ts\", \"prismicCodegen.config.js\"];\n\ntype LoadConfigConfig = {\n\tpath?: string;\n};\n\nexport const loadConfig = async (config: LoadConfigConfig): Promise<Config> => {\n\tif (config.path) {\n\t\tif (existsSync(config.path)) {\n\t\t\treturn await loadModuleWithJiti(resolvePath(config.path));\n\t\t} else {\n\t\t\tthrow new Error(`Config file does not exist: ${config.path}`);\n\t\t}\n\t} else {\n\t\tfor (const configPath of DEFAULT_CONFIG_PATHS) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn await loadModuleWithJiti(resolvePath(configPath));\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config file exists, an empty config is returned.\n\treturn {};\n};\n"],"mappings":";;;;AAOA,MAAM,OAAO,WAAW,QAAQ,IAAI,CAAC;AAErC,MAAM,qBAAqB,OAAgB,OAAiC;CAC3E,OAAO,MAAM,KAAK,OAAgB,IAAI,EAAE,SAAS,KAAK,CAAC;AACxD;AAEA,MAAM,uBAAuB,CAAC,4BAA4B,0BAA0B;AAMpF,MAAa,aAAa,OAAO,WAA8C;CAC9E,IAAI,OAAO,MAAM;EAChB,IAAI,WAAW,OAAO,IAAI,GACzB,OAAO,MAAM,mBAAmBA,QAAY,OAAO,IAAI,CAAC;OAExD,MAAM,IAAI,MAAM,+BAA+B,OAAO,MAAM;CAE9D,OACC,KAAK,MAAM,cAAc,sBACxB,IAAI,WAAW,UAAU,GACxB,OAAO,MAAM,mBAAmBA,QAAY,UAAU,CAAC;CAM1D,OAAO,CAAC;AACT"}
1
+ {"version":3,"file":"loadConfig.mjs","names":["resolvePath"],"sources":["../../src/cli/loadConfig.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport _jiti from \"jiti\";\n\nimport type { Config } from \"./configSchema\";\n\nconst jiti = _jiti(process.cwd());\n\nconst loadModuleWithJiti = <TModule>(id: string): TModule => {\n\tconst mod = jiti(id) as TModule | { default: TModule };\n\n\treturn typeof mod === \"object\" && mod !== null && \"default\" in mod ? mod.default : mod;\n};\n\nconst DEFAULT_CONFIG_PATHS = [\"prismicCodegen.config.ts\", \"prismicCodegen.config.js\"];\n\ntype LoadConfigConfig = {\n\tpath?: string;\n};\n\nexport const loadConfig = (config: LoadConfigConfig): Config => {\n\tif (config.path) {\n\t\tif (existsSync(config.path)) {\n\t\t\treturn loadModuleWithJiti(resolvePath(config.path));\n\t\t} else {\n\t\t\tthrow new Error(`Config file does not exist: ${config.path}`);\n\t\t}\n\t} else {\n\t\tfor (const configPath of DEFAULT_CONFIG_PATHS) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn loadModuleWithJiti(resolvePath(configPath));\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config file exists, an empty config is returned.\n\treturn {};\n};\n"],"mappings":";;;;AAOA,MAAM,OAAO,MAAM,QAAQ,KAAK,CAAC;AAEjC,MAAM,sBAA+B,OAAwB;CAC5D,MAAM,MAAM,KAAK,GAAG;AAEpB,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,aAAa,MAAM,IAAI,UAAU;;AAGpF,MAAM,uBAAuB,CAAC,4BAA4B,2BAA2B;AAMrF,MAAa,cAAc,WAAqC;AAC/D,KAAI,OAAO,KACV,KAAI,WAAW,OAAO,KAAK,CAC1B,QAAO,mBAAmBA,QAAY,OAAO,KAAK,CAAC;KAEnD,OAAM,IAAI,MAAM,+BAA+B,OAAO,OAAO;KAG9D,MAAK,MAAM,cAAc,qBACxB,KAAI,WAAW,WAAW,CACzB,QAAO,mBAAmBA,QAAY,WAAW,CAAC;AAMrD,QAAO,EAAE"}
@@ -1,4 +1,5 @@
1
1
  import * as prismic from "@prismicio/client";
2
+ import fetch from "node-fetch";
2
3
  //#region src/cli/loadLocaleIDs.ts
3
4
  const loadLocaleIDs = async (config) => {
4
5
  const localeIDs = new Set(config.localeIDs || []);
@@ -1 +1 @@
1
- {"version":3,"file":"loadLocaleIDs.mjs","names":[],"sources":["../../src/cli/loadLocaleIDs.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype LoadLocalesConfig =\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t }\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t\t\trepositoryName: string;\n\t\t\taccessToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\nexport const loadLocaleIDs = async (config: LoadLocalesConfig): Promise<string[]> => {\n\tconst localeIDs = new Set<string>(config.localeIDs || []);\n\n\tif (\"repositoryName\" in config && config.fetchFromRepository) {\n\t\tconst client = prismic.createClient(config.repositoryName, {\n\t\t\taccessToken: config.accessToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tconst repository = await client.getRepository();\n\n\t\tfor (const language of repository.languages) {\n\t\t\tlocaleIDs.add(language.id);\n\t\t}\n\t}\n\n\treturn [...localeIDs];\n};\n"],"mappings":";;AAaA,MAAa,gBAAgB,OAAO,WAAiD;CACpF,MAAM,YAAY,IAAI,IAAY,OAAO,aAAa,CAAC,CAAC;CAExD,IAAI,oBAAoB,UAAU,OAAO,qBAAqB;EAM7D,MAAM,aAAa,MALJ,QAAQ,aAAa,OAAO,gBAAgB;GAC1D,aAAa,OAAO;GACpB;EACD,CAE8B,CAAC,CAAC,cAAc;EAE9C,KAAK,MAAM,YAAY,WAAW,WACjC,UAAU,IAAI,SAAS,EAAE;CAE3B;CAEA,OAAO,CAAC,GAAG,SAAS;AACrB"}
1
+ {"version":3,"file":"loadLocaleIDs.mjs","names":[],"sources":["../../src/cli/loadLocaleIDs.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport fetch from \"node-fetch\";\n\ntype LoadLocalesConfig =\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t }\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t\t\trepositoryName: string;\n\t\t\taccessToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\nexport const loadLocaleIDs = async (config: LoadLocalesConfig): Promise<string[]> => {\n\tconst localeIDs = new Set<string>(config.localeIDs || []);\n\n\tif (\"repositoryName\" in config && config.fetchFromRepository) {\n\t\tconst client = prismic.createClient(config.repositoryName, {\n\t\t\taccessToken: config.accessToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tconst repository = await client.getRepository();\n\n\t\tfor (const language of repository.languages) {\n\t\t\tlocaleIDs.add(language.id);\n\t\t}\n\t}\n\n\treturn [...localeIDs];\n};\n"],"mappings":";;;AAcA,MAAa,gBAAgB,OAAO,WAAiD;CACpF,MAAM,YAAY,IAAI,IAAY,OAAO,aAAa,EAAE,CAAC;AAEzD,KAAI,oBAAoB,UAAU,OAAO,qBAAqB;EAM7D,MAAM,aAAa,MALJ,QAAQ,aAAa,OAAO,gBAAgB;GAC1D,aAAa,OAAO;GACpB;GACA,CAAC,CAE8B,eAAe;AAE/C,OAAK,MAAM,YAAY,WAAW,UACjC,WAAU,IAAI,SAAS,GAAG;;AAI5B,QAAO,CAAC,GAAG,UAAU"}
@@ -1,7 +1,8 @@
1
1
  import { readFileSync } from "fs";
2
- import { glob } from "tinyglobby";
2
+ import fetch from "node-fetch";
3
+ import * as prismicCT from "@prismicio/custom-types-client";
4
+ import fg from "fast-glob";
3
5
  //#region src/cli/loadModels.ts
4
- const CUSTOM_TYPES_API_ENDPOINT = "https://customtypes.prismic.io/";
5
6
  const isCustomTypeModel = (input) => {
6
7
  return typeof input === "object" && input !== null && "json" in input;
7
8
  };
@@ -9,26 +10,22 @@ const isSharedSliceModel = (input) => {
9
10
  return typeof input === "object" && input !== null && "variations" in input;
10
11
  };
11
12
  const readJSONFromGlob = async (globs) => {
12
- return (await glob(globs.split(",").map((path) => path.trim()), { expandDirectories: false })).map((path) => {
13
+ return (await fg(globs.split(",").map((path) => path.trim()))).map((path) => {
13
14
  const raw = readFileSync(path, "utf8");
14
15
  return JSON.parse(raw);
15
16
  });
16
17
  };
17
- const fetchCustomTypesAPI = async (path, config) => {
18
- const url = new URL(path, CUSTOM_TYPES_API_ENDPOINT);
19
- const res = await fetch(url, { headers: {
20
- repository: config.repositoryName,
21
- Authorization: `Bearer ${config.customTypesAPIToken}`
22
- } });
23
- if (!res.ok) throw new Error(`Failed to fetch models from the Custom Types API (${res.status}): ${await res.text()}`);
24
- return await res.json();
25
- };
26
18
  const loadModels = async (config) => {
27
19
  const customTypeModels = {};
28
20
  const sharedSliceModels = {};
29
21
  if ("customTypesAPIToken" in config) {
22
+ const customTypesClient = prismicCT.createClient({
23
+ repositoryName: config.repositoryName,
24
+ token: config.customTypesAPIToken,
25
+ fetch
26
+ });
30
27
  if (config.fetchFromRepository) {
31
- const [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([fetchCustomTypesAPI("customtypes", config), fetchCustomTypesAPI("slices", config)]);
28
+ const [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([customTypesClient.getAllCustomTypes(), customTypesClient.getAllSharedSlices()]);
32
29
  for (const customTypeModel of remoteCustomTypeModels) customTypeModels[customTypeModel.id] = customTypeModel;
33
30
  for (const sharedSliceModel of remoteSharedSliceModels) sharedSliceModels[sharedSliceModel.id] = sharedSliceModel;
34
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loadModels.mjs","names":[],"sources":["../../src/cli/loadModels.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\n\nimport type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { glob } from \"tinyglobby\";\n\nconst CUSTOM_TYPES_API_ENDPOINT = \"https://customtypes.prismic.io/\";\n\nconst isCustomTypeModel = (input: unknown): input is CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nconst isSharedSliceModel = (input: unknown): input is SharedSliceModel => {\n\treturn typeof input === \"object\" && input !== null && \"variations\" in input;\n};\n\nconst readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {\n\tconst paths = await glob(\n\t\tglobs.split(\",\").map((path) => path.trim()),\n\t\t{ expandDirectories: false },\n\t);\n\n\treturn paths.map((path) => {\n\t\tconst raw = readFileSync(path, \"utf8\");\n\n\t\treturn JSON.parse(raw);\n\t});\n};\n\nconst fetchCustomTypesAPI = async <T>(\n\tpath: string,\n\tconfig: { repositoryName: string; customTypesAPIToken: string },\n): Promise<T[]> => {\n\tconst url = new URL(path, CUSTOM_TYPES_API_ENDPOINT);\n\tconst res = await fetch(url, {\n\t\theaders: {\n\t\t\trepository: config.repositoryName,\n\t\t\tAuthorization: `Bearer ${config.customTypesAPIToken}`,\n\t\t},\n\t});\n\n\tif (!res.ok) {\n\t\tthrow new Error(\n\t\t\t`Failed to fetch models from the Custom Types API (${res.status}): ${await res.text()}`,\n\t\t);\n\t}\n\n\treturn await res.json();\n};\n\ntype LoadModelsConfig =\n\t| {\n\t\t\tlocalPaths?: string[];\n\t }\n\t| {\n\t\t\tlocalPaths?: string[];\n\t\t\trepositoryName: string;\n\t\t\tcustomTypesAPIToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\ntype LoadModelsReturnType = {\n\tcustomTypeModels: CustomTypeModel[];\n\tsharedSliceModels: SharedSliceModel[];\n};\n\nexport const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsReturnType> => {\n\tconst customTypeModels: Record<string, CustomTypeModel> = {};\n\tconst sharedSliceModels: Record<string, SharedSliceModel> = {};\n\n\tif (\"customTypesAPIToken\" in config) {\n\t\tif (config.fetchFromRepository) {\n\t\t\tconst [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([\n\t\t\t\tfetchCustomTypesAPI<CustomTypeModel>(\"customtypes\", config),\n\t\t\t\tfetchCustomTypesAPI<SharedSliceModel>(\"slices\", config),\n\t\t\t]);\n\n\t\t\tfor (const customTypeModel of remoteCustomTypeModels) {\n\t\t\t\tcustomTypeModels[customTypeModel.id] = customTypeModel;\n\t\t\t}\n\t\t\tfor (const sharedSliceModel of remoteSharedSliceModels) {\n\t\t\t\tsharedSliceModels[sharedSliceModel.id] = sharedSliceModel;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.localPaths) {\n\t\tconst models = (\n\t\t\tawait Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))\n\t\t).flat();\n\n\t\tfor (const model of models) {\n\t\t\tif (isCustomTypeModel(model)) {\n\t\t\t\tcustomTypeModels[model.id] = model;\n\t\t\t} else if (isSharedSliceModel(model)) {\n\t\t\t\tsharedSliceModels[model.id] = model;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcustomTypeModels: Object.values(customTypeModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t\tsharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t};\n};\n"],"mappings":";;;AAKA,MAAM,4BAA4B;AAElC,MAAM,qBAAqB,UAA6C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEA,MAAM,sBAAsB,UAA8C;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;AACvE;AAEA,MAAM,mBAAmB,OAAU,UAAgC;CAMlE,QAAO,MALa,KACnB,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,GAC1C,EAAE,mBAAmB,MAAM,CAC5B,EAAA,CAEa,KAAK,SAAS;EAC1B,MAAM,MAAM,aAAa,MAAM,MAAM;EAErC,OAAO,KAAK,MAAM,GAAG;CACtB,CAAC;AACF;AAEA,MAAM,sBAAsB,OAC3B,MACA,WACkB;CAClB,MAAM,MAAM,IAAI,IAAI,MAAM,yBAAyB;CACnD,MAAM,MAAM,MAAM,MAAM,KAAK,EAC5B,SAAS;EACR,YAAY,OAAO;EACnB,eAAe,UAAU,OAAO;CACjC,EACD,CAAC;CAED,IAAI,CAAC,IAAI,IACR,MAAM,IAAI,MACT,qDAAqD,IAAI,OAAO,KAAK,MAAM,IAAI,KAAK,GACrF;CAGD,OAAO,MAAM,IAAI,KAAK;AACvB;AAkBA,MAAa,aAAa,OAAO,WAA4D;CAC5F,MAAM,mBAAoD,CAAC;CAC3D,MAAM,oBAAsD,CAAC;CAE7D,IAAI,yBAAyB,QACxB;MAAA,OAAO,qBAAqB;GAC/B,MAAM,CAAC,wBAAwB,2BAA2B,MAAM,QAAQ,IAAI,CAC3E,oBAAqC,eAAe,MAAM,GAC1D,oBAAsC,UAAU,MAAM,CACvD,CAAC;GAED,KAAK,MAAM,mBAAmB,wBAC7B,iBAAiB,gBAAgB,MAAM;GAExC,KAAK,MAAM,oBAAoB,yBAC9B,kBAAkB,iBAAiB,MAAM;EAE3C;;CAGD,IAAI,OAAO,YAAY;EACtB,MAAM,UACL,MAAM,QAAQ,IAAI,OAAO,WAAW,KAAK,SAAS,iBAAiB,IAAI,CAAC,CAAC,EAAA,CACxE,KAAK;EAEP,KAAK,MAAM,SAAS,QACnB,IAAI,kBAAkB,KAAK,GAC1B,iBAAiB,MAAM,MAAM;OACvB,IAAI,mBAAmB,KAAK,GAClC,kBAAkB,MAAM,MAAM;CAGjC;CAEA,OAAO;EACN,kBAAkB,OAAO,OAAO,gBAAgB,CAAC,CAAC,MAAM,GAAG,MAAM;GAChE,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE;EAC/B,CAAC;EACD,mBAAmB,OAAO,OAAO,iBAAiB,CAAC,CAAC,MAAM,GAAG,MAAM;GAClE,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE;EAC/B,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"loadModels.mjs","names":[],"sources":["../../src/cli/loadModels.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\n\nimport type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport * as prismicCT from \"@prismicio/custom-types-client\";\nimport fg from \"fast-glob\";\nimport fetch from \"node-fetch\";\n\nconst isCustomTypeModel = (input: unknown): input is CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nconst isSharedSliceModel = (input: unknown): input is SharedSliceModel => {\n\treturn typeof input === \"object\" && input !== null && \"variations\" in input;\n};\n\nconst readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {\n\tconst paths = await fg(globs.split(\",\").map((path) => path.trim()));\n\n\treturn paths.map((path) => {\n\t\tconst raw = readFileSync(path, \"utf8\");\n\n\t\treturn JSON.parse(raw);\n\t});\n};\n\ntype LoadModelsConfig =\n\t| {\n\t\t\tlocalPaths?: string[];\n\t }\n\t| {\n\t\t\tlocalPaths?: string[];\n\t\t\trepositoryName: string;\n\t\t\tcustomTypesAPIToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\ntype LoadModelsReturnType = {\n\tcustomTypeModels: CustomTypeModel[];\n\tsharedSliceModels: SharedSliceModel[];\n};\n\nexport const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsReturnType> => {\n\tconst customTypeModels: Record<string, CustomTypeModel> = {};\n\tconst sharedSliceModels: Record<string, SharedSliceModel> = {};\n\n\tif (\"customTypesAPIToken\" in config) {\n\t\tconst customTypesClient = prismicCT.createClient({\n\t\t\trepositoryName: config.repositoryName,\n\t\t\ttoken: config.customTypesAPIToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tif (config.fetchFromRepository) {\n\t\t\tconst [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([\n\t\t\t\tcustomTypesClient.getAllCustomTypes(),\n\t\t\t\tcustomTypesClient.getAllSharedSlices(),\n\t\t\t]);\n\n\t\t\tfor (const customTypeModel of remoteCustomTypeModels) {\n\t\t\t\tcustomTypeModels[customTypeModel.id] = customTypeModel;\n\t\t\t}\n\t\t\tfor (const sharedSliceModel of remoteSharedSliceModels) {\n\t\t\t\tsharedSliceModels[sharedSliceModel.id] = sharedSliceModel;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.localPaths) {\n\t\tconst models = (\n\t\t\tawait Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))\n\t\t).flat();\n\n\t\tfor (const model of models) {\n\t\t\tif (isCustomTypeModel(model)) {\n\t\t\t\tcustomTypeModels[model.id] = model;\n\t\t\t} else if (isSharedSliceModel(model)) {\n\t\t\t\tsharedSliceModels[model.id] = model;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcustomTypeModels: Object.values(customTypeModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t\tsharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t};\n};\n"],"mappings":";;;;;AAOA,MAAM,qBAAqB,UAA6C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;;AAGjE,MAAM,sBAAsB,UAA8C;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;;AAGvE,MAAM,mBAAmB,OAAU,UAAgC;AAGlE,SAFc,MAAM,GAAG,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,EAEtD,KAAK,SAAS;EAC1B,MAAM,MAAM,aAAa,MAAM,OAAO;AAEtC,SAAO,KAAK,MAAM,IAAI;GACrB;;AAmBH,MAAa,aAAa,OAAO,WAA4D;CAC5F,MAAM,mBAAoD,EAAE;CAC5D,MAAM,oBAAsD,EAAE;AAE9D,KAAI,yBAAyB,QAAQ;EACpC,MAAM,oBAAoB,UAAU,aAAa;GAChD,gBAAgB,OAAO;GACvB,OAAO,OAAO;GACd;GACA,CAAC;AAEF,MAAI,OAAO,qBAAqB;GAC/B,MAAM,CAAC,wBAAwB,2BAA2B,MAAM,QAAQ,IAAI,CAC3E,kBAAkB,mBAAmB,EACrC,kBAAkB,oBAAoB,CACtC,CAAC;AAEF,QAAK,MAAM,mBAAmB,uBAC7B,kBAAiB,gBAAgB,MAAM;AAExC,QAAK,MAAM,oBAAoB,wBAC9B,mBAAkB,iBAAiB,MAAM;;;AAK5C,KAAI,OAAO,YAAY;EACtB,MAAM,UACL,MAAM,QAAQ,IAAI,OAAO,WAAW,KAAK,SAAS,iBAAiB,KAAK,CAAC,CAAC,EACzE,MAAM;AAER,OAAK,MAAM,SAAS,OACnB,KAAI,kBAAkB,MAAM,CAC3B,kBAAiB,MAAM,MAAM;WACnB,mBAAmB,MAAM,CACnC,mBAAkB,MAAM,MAAM;;AAKjC,QAAO;EACN,kBAAkB,OAAO,OAAO,iBAAiB,CAAC,MAAM,GAAG,MAAM;AAChE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF,mBAAmB,OAAO,OAAO,kBAAkB,CAAC,MAAM,GAAG,MAAM;AAClE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF"}
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
- export {}
1
+ export { };
package/dist/cli.mjs CHANGED
@@ -1,20 +1,17 @@
1
- import { dedent } from "./lib/dedent.mjs";
2
1
  import { generateTypes } from "./generateTypes.mjs";
3
2
  import { detectTypesProvider } from "./detectTypesProvider.mjs";
4
3
  import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.mjs";
5
4
  import "./index.mjs";
6
- import { description, version } from "./package.mjs";
7
5
  import { configSchema } from "./cli/configSchema.mjs";
8
6
  import { loadConfig } from "./cli/loadConfig.mjs";
9
7
  import { loadLocaleIDs } from "./cli/loadLocaleIDs.mjs";
10
8
  import { loadModels } from "./cli/loadModels.mjs";
9
+ import { stripIndent } from "common-tags";
11
10
  import { existsSync, writeFileSync } from "fs";
12
- import { parseArgs } from "node:util";
13
11
  import { resolve } from "path";
12
+ import meow from "meow";
14
13
  //#region src/cli/index.ts
15
- const HELP = dedent`
16
- ${description}
17
-
14
+ const cli = meow(`
18
15
  Usage:
19
16
  prismic-ts-codegen [options...]
20
17
  prismic-ts-codegen init [options...]
@@ -24,43 +21,21 @@ const HELP = dedent`
24
21
 
25
22
  Options:
26
23
  -c, --config <path> Path to a prismic-ts-codegen configuration file.
27
- -h, --help Show this help.
28
- -v, --version Show the version.
29
- `;
24
+ `, {
25
+ importMeta: import.meta,
26
+ flags: { config: {
27
+ type: "string",
28
+ shortFlag: "c",
29
+ isRequired: false
30
+ } }
31
+ });
30
32
  const main = async () => {
31
- const { positionals: [command], values: { config: configFlag, help, version: version$1 } } = parseArgs({
32
- options: {
33
- config: {
34
- type: "string",
35
- short: "c"
36
- },
37
- help: {
38
- type: "boolean",
39
- short: "h"
40
- },
41
- version: {
42
- type: "boolean",
43
- short: "v"
44
- }
45
- },
46
- allowPositionals: true,
47
- strict: false
48
- });
49
- const configPathFlag = typeof configFlag === "string" ? configFlag : void 0;
50
- if (help) {
51
- console.info(`\n${HELP}\n`);
52
- return;
53
- }
54
- if (version$1) {
55
- console.info(version);
56
- return;
57
- }
58
- if (command === "init") {
59
- const configPath = configPathFlag || "prismicCodegen.config.ts";
33
+ if (cli.input[0] === "init") {
34
+ const configPath = cli.flags.config || "prismicCodegen.config.ts";
60
35
  if (existsSync(configPath)) console.info(`\n${configPath} already exists.`);
61
36
  else {
62
37
  let contents = "";
63
- if (existsSync("slicemachine.config.json") || existsSync("sm.json")) contents = dedent`
38
+ if (existsSync("slicemachine.config.json") || existsSync("sm.json")) contents = stripIndent`
64
39
  import type { Config } from "prismic-ts-codegen";
65
40
 
66
41
  const config: Config = {
@@ -70,7 +45,7 @@ const main = async () => {
70
45
 
71
46
  export default config;
72
47
  `;
73
- else contents = dedent`
48
+ else contents = stripIndent`
74
49
  import type { Config } from "prismic-ts-codegen";
75
50
 
76
51
  const config: Config = {
@@ -83,7 +58,7 @@ const main = async () => {
83
58
  console.info(`\nCreated prismic-ts-codegen config file: ${configPath}`);
84
59
  }
85
60
  } else {
86
- const unvalidatedConfig = await loadConfig({ path: configPathFlag });
61
+ const unvalidatedConfig = loadConfig({ path: cli.flags.config });
87
62
  const result = configSchema.safeParse(unvalidatedConfig);
88
63
  if (result.success) {
89
64
  const config = result.data;
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":["packageJson.description","version","packageJson.version","resolvePath"],"sources":["../src/cli/index.ts"],"sourcesContent":["import { existsSync, writeFileSync } from \"fs\";\nimport { parseArgs } from \"node:util\";\nimport { resolve as resolvePath } from \"path\";\n\nimport packageJson from \"../../package.json\" with { type: \"json\" };\nimport { detectTypesProvider, generateTypes } from \"../index\";\nimport { dedent } from \"../lib/dedent\";\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst HELP = dedent`\n\t${packageJson.description}\n\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t -h, --help Show this help.\n\t -v, --version Show the version.\n`;\n\nconst main = async () => {\n\tconst {\n\t\tpositionals: [command],\n\t\tvalues: { config: configFlag, help, version },\n\t} = parseArgs({\n\t\toptions: {\n\t\t\tconfig: { type: \"string\", short: \"c\" },\n\t\t\thelp: { type: \"boolean\", short: \"h\" },\n\t\t\tversion: { type: \"boolean\", short: \"v\" },\n\t\t},\n\t\tallowPositionals: true,\n\t\tstrict: false,\n\t});\n\tconst configPathFlag = typeof configFlag === \"string\" ? configFlag : undefined;\n\n\tif (help) {\n\t\tconsole.info(`\\n${HELP}\\n`);\n\t\treturn;\n\t}\n\n\tif (version) {\n\t\tconsole.info(packageJson.version);\n\t\treturn;\n\t}\n\n\tif (command === \"init\") {\n\t\tconst configPath = configPathFlag || \"prismicCodegen.config.ts\";\n\n\t\tif (existsSync(configPath)) {\n\t\t\tconsole.info(`\\n${configPath} already exists.`);\n\t\t} else {\n\t\t\tlet contents = \"\";\n\n\t\t\tif (existsSync(\"slicemachine.config.json\") || existsSync(\"sm.json\")) {\n\t\t\t\tcontents = dedent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t models: [\"./customtypes/**/index.json\", \"./slices/**/model.json\"],\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tcontents = dedent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t}\n\n\t\t\twriteFileSync(configPath, contents);\n\n\t\t\tconsole.info(`\\nCreated prismic-ts-codegen config file: ${configPath}`);\n\t\t}\n\t} else {\n\t\tconst unvalidatedConfig = await loadConfig({ path: configPathFlag });\n\n\t\tconst result = configSchema.safeParse(unvalidatedConfig);\n\n\t\tif (result.success) {\n\t\t\tconst config = result.data;\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models) ? config.models : config.models?.files,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\tcustomTypesAPIToken: config.customTypesAPIToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.models &&\n\t\t\t\t\t\"fetchFromRepository\" in config.models &&\n\t\t\t\t\tconfig.models.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst localeIDs = await loadLocaleIDs({\n\t\t\t\tlocaleIDs: Array.isArray(config.locales) ? config.locales : config.locales?.ids,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\taccessToken: config.accessToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.locales &&\n\t\t\t\t\t\"fetchFromRepository\" in config.locales &&\n\t\t\t\t\tconfig.locales.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst typesProvider = config.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) {\n\t\t\t\tconsole.info(\n\t\t\t\t\t\"[INFO]: prismic-ts-codegen was configured to automatically integrate with `@prismicio/client`, but the integration was not generated because no Custom Type models were found. Automatic integration requires at least one Custom Type model.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst types = generateTypes({\n\t\t\t\tcustomTypeModels,\n\t\t\t\tsharedSliceModels,\n\t\t\t\tlocaleIDs,\n\t\t\t\tfieldConfigs: config.fields,\n\t\t\t\tclientIntegration: {\n\t\t\t\t\tincludeCreateClientInterface: hasCustomTypeModels\n\t\t\t\t\t\t? (config.clientIntegration?.includeCreateClientInterface ?? true)\n\t\t\t\t\t\t: false,\n\t\t\t\t\tincludeContentNamespace: config.clientIntegration?.includeContentNamespace ?? true,\n\t\t\t\t},\n\t\t\t\ttypesProvider,\n\t\t\t});\n\n\t\t\tconst fileContents = `${NON_EDITABLE_FILE_HEADER}\\n\\n${types}`;\n\n\t\t\tif (config.output) {\n\t\t\t\twriteFileSync(resolvePath(config.output), fileContents);\n\n\t\t\t\tconsole.info(`\\nGenerated types in: ${config.output}`);\n\t\t\t} else {\n\t\t\t\tprocess.stdout.write(types + \"\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error(result.error.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n};\n\nmain().catch((error) => {\n\tconsole.error(error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,OAAO,MAAM;GAChBA,YAAwB;;;;;;;;;;;;;;AAe3B,MAAM,OAAO,YAAY;CACxB,MAAM,EACL,aAAa,CAAC,UACd,QAAQ,EAAE,QAAQ,YAAY,MAAM,SAAA,gBACjC,UAAU;EACb,SAAS;GACR,QAAQ;IAAE,MAAM;IAAU,OAAO;GAAI;GACrC,MAAM;IAAE,MAAM;IAAW,OAAO;GAAI;GACpC,SAAS;IAAE,MAAM;IAAW,OAAO;GAAI;EACxC;EACA,kBAAkB;EAClB,QAAQ;CACT,CAAC;CACD,MAAM,iBAAiB,OAAO,eAAe,WAAW,aAAa,KAAA;CAErE,IAAI,MAAM;EACT,QAAQ,KAAK,KAAK,KAAK,GAAG;EAC1B;CACD;CAEA,IAAIC,WAAS;EACZ,QAAQ,KAAKC,OAAmB;EAChC;CACD;CAEA,IAAI,YAAY,QAAQ;EACvB,MAAM,aAAa,kBAAkB;EAErC,IAAI,WAAW,UAAU,GACxB,QAAQ,KAAK,KAAK,WAAW,iBAAiB;OACxC;GACN,IAAI,WAAW;GAEf,IAAI,WAAW,0BAA0B,KAAK,WAAW,SAAS,GACjE,WAAW,MAAM;;;;;;;;;;QAWjB,WAAW,MAAM;;;;;;;;;GAWlB,cAAc,YAAY,QAAQ;GAElC,QAAQ,KAAK,6CAA6C,YAAY;EACvE;CACD,OAAO;EACN,MAAM,oBAAoB,MAAM,WAAW,EAAE,MAAM,eAAe,CAAC;EAEnE,MAAM,SAAS,aAAa,UAAU,iBAAiB;EAEvD,IAAI,OAAO,SAAS;GACnB,MAAM,SAAS,OAAO;GACtB,MAAM,EAAE,kBAAkB,sBAAsB,MAAM,WAAW;IAChE,YAAY,MAAM,QAAQ,OAAO,MAAM,IAAI,OAAO,SAAS,OAAO,QAAQ;IAC1E,gBAAgB,OAAO;IACvB,qBAAqB,OAAO;IAC5B,qBACC,OAAO,UACP,yBAAyB,OAAO,UAChC,OAAO,OAAO;GAChB,CAAC;GAED,MAAM,YAAY,MAAM,cAAc;IACrC,WAAW,MAAM,QAAQ,OAAO,OAAO,IAAI,OAAO,UAAU,OAAO,SAAS;IAC5E,gBAAgB,OAAO;IACvB,aAAa,OAAO;IACpB,qBACC,OAAO,WACP,yBAAyB,OAAO,WAChC,OAAO,QAAQ;GACjB,CAAC;GAED,MAAM,gBAAgB,OAAO,iBAAkB,MAAM,oBAAoB;GAEzE,MAAM,sBAAsB,iBAAiB,SAAS;GAEtD,IAAI,OAAO,mBAAmB,gCAAgC,CAAC,qBAC9D,QAAQ,KACP,+OACD;GAGD,MAAM,QAAQ,cAAc;IAC3B;IACA;IACA;IACA,cAAc,OAAO;IACrB,mBAAmB;KAClB,8BAA8B,sBAC1B,OAAO,mBAAmB,gCAAgC,OAC3D;KACH,yBAAyB,OAAO,mBAAmB,2BAA2B;IAC/E;IACA;GACD,CAAC;GAED,MAAM,eAAe,GAAG,yBAAyB,MAAM;GAEvD,IAAI,OAAO,QAAQ;IAClB,cAAcC,QAAY,OAAO,MAAM,GAAG,YAAY;IAEtD,QAAQ,KAAK,yBAAyB,OAAO,QAAQ;GACtD,OACC,QAAQ,OAAO,MAAM,QAAQ,IAAI;EAEnC,OAAO;GACN,QAAQ,MAAM,OAAO,MAAM,OAAO;GAClC,QAAQ,KAAK,CAAC;EACf;CACD;AACD;AAEA,KAAK,CAAC,CAAC,OAAO,UAAU;CACvB,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"cli.mjs","names":["resolvePath"],"sources":["../src/cli/index.ts"],"sourcesContent":["import { existsSync, writeFileSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { stripIndent } from \"common-tags\";\nimport meow from \"meow\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst cli = meow(\n\t`\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t`,\n\t{\n\t\timportMeta: import.meta,\n\t\tflags: {\n\t\t\tconfig: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tshortFlag: \"c\",\n\t\t\t\tisRequired: false,\n\t\t\t},\n\t\t},\n\t},\n);\n\nconst main = async () => {\n\tif (cli.input[0] === \"init\") {\n\t\tconst configPath = cli.flags.config || \"prismicCodegen.config.ts\";\n\n\t\tif (existsSync(configPath)) {\n\t\t\tconsole.info(`\\n${configPath} already exists.`);\n\t\t} else {\n\t\t\tlet contents = \"\";\n\n\t\t\tif (existsSync(\"slicemachine.config.json\") || existsSync(\"sm.json\")) {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t models: [\"./customtypes/**/index.json\", \"./slices/**/model.json\"],\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t}\n\n\t\t\twriteFileSync(configPath, contents);\n\n\t\t\tconsole.info(`\\nCreated prismic-ts-codegen config file: ${configPath}`);\n\t\t}\n\t} else {\n\t\tconst unvalidatedConfig = loadConfig({ path: cli.flags.config });\n\n\t\tconst result = configSchema.safeParse(unvalidatedConfig);\n\n\t\tif (result.success) {\n\t\t\tconst config = result.data;\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models) ? config.models : config.models?.files,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\tcustomTypesAPIToken: config.customTypesAPIToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.models &&\n\t\t\t\t\t\"fetchFromRepository\" in config.models &&\n\t\t\t\t\tconfig.models.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst localeIDs = await loadLocaleIDs({\n\t\t\t\tlocaleIDs: Array.isArray(config.locales) ? config.locales : config.locales?.ids,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\taccessToken: config.accessToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.locales &&\n\t\t\t\t\t\"fetchFromRepository\" in config.locales &&\n\t\t\t\t\tconfig.locales.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst typesProvider = config.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) {\n\t\t\t\tconsole.info(\n\t\t\t\t\t\"[INFO]: prismic-ts-codegen was configured to automatically integrate with `@prismicio/client`, but the integration was not generated because no Custom Type models were found. Automatic integration requires at least one Custom Type model.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst types = generateTypes({\n\t\t\t\tcustomTypeModels,\n\t\t\t\tsharedSliceModels,\n\t\t\t\tlocaleIDs,\n\t\t\t\tfieldConfigs: config.fields,\n\t\t\t\tclientIntegration: {\n\t\t\t\t\tincludeCreateClientInterface: hasCustomTypeModels\n\t\t\t\t\t\t? (config.clientIntegration?.includeCreateClientInterface ?? true)\n\t\t\t\t\t\t: false,\n\t\t\t\t\tincludeContentNamespace: config.clientIntegration?.includeContentNamespace ?? true,\n\t\t\t\t},\n\t\t\t\ttypesProvider,\n\t\t\t});\n\n\t\t\tconst fileContents = `${NON_EDITABLE_FILE_HEADER}\\n\\n${types}`;\n\n\t\t\tif (config.output) {\n\t\t\t\twriteFileSync(resolvePath(config.output), fileContents);\n\n\t\t\t\tconsole.info(`\\nGenerated types in: ${config.output}`);\n\t\t\t} else {\n\t\t\t\tprocess.stdout.write(types + \"\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error(result.error.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n};\n\nmain().catch((error) => {\n\tconsole.error(error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,MAAM,KACX;;;;;;;;;;IAWA;CACC,YAAY,OAAO;CACnB,OAAO,EACN,QAAQ;EACP,MAAM;EACN,WAAW;EACX,YAAY;EACZ,EACD;CACD,CACD;AAED,MAAM,OAAO,YAAY;AACxB,KAAI,IAAI,MAAM,OAAO,QAAQ;EAC5B,MAAM,aAAa,IAAI,MAAM,UAAU;AAEvC,MAAI,WAAW,WAAW,CACzB,SAAQ,KAAK,KAAK,WAAW,kBAAkB;OACzC;GACN,IAAI,WAAW;AAEf,OAAI,WAAW,2BAA2B,IAAI,WAAW,UAAU,CAClE,YAAW,WAAW;;;;;;;;;;OAWtB,YAAW,WAAW;;;;;;;;;AAWvB,iBAAc,YAAY,SAAS;AAEnC,WAAQ,KAAK,6CAA6C,aAAa;;QAElE;EACN,MAAM,oBAAoB,WAAW,EAAE,MAAM,IAAI,MAAM,QAAQ,CAAC;EAEhE,MAAM,SAAS,aAAa,UAAU,kBAAkB;AAExD,MAAI,OAAO,SAAS;GACnB,MAAM,SAAS,OAAO;GACtB,MAAM,EAAE,kBAAkB,sBAAsB,MAAM,WAAW;IAChE,YAAY,MAAM,QAAQ,OAAO,OAAO,GAAG,OAAO,SAAS,OAAO,QAAQ;IAC1E,gBAAgB,OAAO;IACvB,qBAAqB,OAAO;IAC5B,qBACC,OAAO,UACP,yBAAyB,OAAO,UAChC,OAAO,OAAO;IACf,CAAC;GAEF,MAAM,YAAY,MAAM,cAAc;IACrC,WAAW,MAAM,QAAQ,OAAO,QAAQ,GAAG,OAAO,UAAU,OAAO,SAAS;IAC5E,gBAAgB,OAAO;IACvB,aAAa,OAAO;IACpB,qBACC,OAAO,WACP,yBAAyB,OAAO,WAChC,OAAO,QAAQ;IAChB,CAAC;GAEF,MAAM,gBAAgB,OAAO,iBAAkB,MAAM,qBAAqB;GAE1E,MAAM,sBAAsB,iBAAiB,SAAS;AAEtD,OAAI,OAAO,mBAAmB,gCAAgC,CAAC,oBAC9D,SAAQ,KACP,gPACA;GAGF,MAAM,QAAQ,cAAc;IAC3B;IACA;IACA;IACA,cAAc,OAAO;IACrB,mBAAmB;KAClB,8BAA8B,sBAC1B,OAAO,mBAAmB,gCAAgC,OAC3D;KACH,yBAAyB,OAAO,mBAAmB,2BAA2B;KAC9E;IACD;IACA,CAAC;GAEF,MAAM,eAAe,GAAG,yBAAyB,MAAM;AAEvD,OAAI,OAAO,QAAQ;AAClB,kBAAcA,QAAY,OAAO,OAAO,EAAE,aAAa;AAEvD,YAAQ,KAAK,yBAAyB,OAAO,SAAS;SAEtD,SAAQ,OAAO,MAAM,QAAQ,KAAK;SAE7B;AACN,WAAQ,MAAM,OAAO,MAAM,QAAQ;AACnC,WAAQ,KAAK,EAAE;;;;AAKlB,MAAM,CAAC,OAAO,UAAU;AACvB,SAAQ,MAAM,MAAM;AACpB,SAAQ,KAAK,EAAE;EACd"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"@prismicio/client\";\n\nexport const CUSTOM_TYPES_DOCUMENTATION_URL = \"https://prismic.io/docs/content-modeling\";\n\nexport const SHARED_SLICES_DOCUMENTATION_URL = \"https://prismic.io/docs/slices\";\n\nexport const FIELD_DOCUMENTATION_URLS = {\n\tUID: \"https://prismic.io/docs/fields/uid\",\n\tBoolean: \"https://prismic.io/docs/fields/boolean\",\n\tColor: \"https://prismic.io/docs/fields/color\",\n\tDate: \"https://prismic.io/docs/fields/date\",\n\tTimestamp: \"https://prismic.io/docs/fields/timestamp\",\n\tNumber: \"https://prismic.io/docs/fields/number\",\n\tText: \"https://prismic.io/docs/fields/text\",\n\tSelect: \"https://prismic.io/docs/fields/select\",\n\tStructuredText: \"https://prismic.io/docs/fields/rich-text\",\n\tImage: \"https://prismic.io/docs/fields/image\",\n\tLink: {\n\t\tcontentRelationship: \"https://prismic.io/docs/fields/content-relationship\",\n\t\tlink: \"https://prismic.io/docs/fields/link\",\n\t\tlinkToMedia: \"https://prismic.io/docs/fields/link-to-media\",\n\t},\n\tEmbed: \"https://prismic.io/docs/fields/embed\",\n\tGeoPoint: \"https://prismic.io/docs/fields/geopoint\",\n\tTable: \"https://prismic.io/docs/fields/table\",\n\tGroup: \"https://prismic.io/docs/fields/repeatable-group\",\n\tIntegrationFields: \"https://prismic.io/docs/fields/integration\",\n\tSlices: \"https://prismic.io/docs/slices\",\n\tChoice: \"https://prismic.io/docs/slices\",\n} satisfies Record<\n\tExclude<\n\t\t(typeof CustomTypeModelFieldType)[keyof typeof CustomTypeModelFieldType],\n\t\t\"Range\" | \"Separator\"\n\t>,\n\tstring | Record<string, string>\n>;\n"],"mappings":";AAEA,MAAa,iCAAiC;AAE9C,MAAa,kCAAkC;AAE/C,MAAa,2BAA2B;CACvC,KAAK;CACL,SAAS;CACT,OAAO;CACP,MAAM;CACN,WAAW;CACX,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,MAAM;EACL,qBAAqB;EACrB,MAAM;EACN,aAAa;CACd;CACA,OAAO;CACP,UAAU;CACV,OAAO;CACP,OAAO;CACP,mBAAmB;CACnB,QAAQ;CACR,QAAQ;AACT"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"@prismicio/client\";\n\nexport const CUSTOM_TYPES_DOCUMENTATION_URL = \"https://prismic.io/docs/content-modeling\";\n\nexport const SHARED_SLICES_DOCUMENTATION_URL = \"https://prismic.io/docs/slices\";\n\nexport const FIELD_DOCUMENTATION_URLS = {\n\tUID: \"https://prismic.io/docs/fields/uid\",\n\tBoolean: \"https://prismic.io/docs/fields/boolean\",\n\tColor: \"https://prismic.io/docs/fields/color\",\n\tDate: \"https://prismic.io/docs/fields/date\",\n\tTimestamp: \"https://prismic.io/docs/fields/timestamp\",\n\tNumber: \"https://prismic.io/docs/fields/number\",\n\tText: \"https://prismic.io/docs/fields/text\",\n\tSelect: \"https://prismic.io/docs/fields/select\",\n\tStructuredText: \"https://prismic.io/docs/fields/rich-text\",\n\tImage: \"https://prismic.io/docs/fields/image\",\n\tLink: {\n\t\tcontentRelationship: \"https://prismic.io/docs/fields/content-relationship\",\n\t\tlink: \"https://prismic.io/docs/fields/link\",\n\t\tlinkToMedia: \"https://prismic.io/docs/fields/link-to-media\",\n\t},\n\tEmbed: \"https://prismic.io/docs/fields/embed\",\n\tGeoPoint: \"https://prismic.io/docs/fields/geopoint\",\n\tTable: \"https://prismic.io/docs/fields/table\",\n\tGroup: \"https://prismic.io/docs/fields/repeatable-group\",\n\tIntegrationFields: \"https://prismic.io/docs/fields/integration\",\n\tSlices: \"https://prismic.io/docs/slices\",\n\tChoice: \"https://prismic.io/docs/slices\",\n} satisfies Record<\n\tExclude<\n\t\t(typeof CustomTypeModelFieldType)[keyof typeof CustomTypeModelFieldType],\n\t\t\"Range\" | \"Separator\"\n\t>,\n\tstring | Record<string, string>\n>;\n"],"mappings":";AAEA,MAAa,iCAAiC;AAE9C,MAAa,kCAAkC;AAE/C,MAAa,2BAA2B;CACvC,KAAK;CACL,SAAS;CACT,OAAO;CACP,MAAM;CACN,WAAW;CACX,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,MAAM;EACL,qBAAqB;EACrB,MAAM;EACN,aAAa;EACb;CACD,OAAO;CACP,UAAU;CACV,OAAO;CACP,OAAO;CACP,mBAAmB;CACnB,QAAQ;CACR,QAAQ;CACR"}
@@ -1,6 +1,7 @@
1
1
  import { TypesProvider } from "./generateTypes.mjs";
2
+
2
3
  //#region src/detectTypesProvider.d.ts
3
- export type DetectTypesProviderConfig = {
4
+ type DetectTypesProviderConfig = {
4
5
  cwd?: string;
5
6
  };
6
7
  /**
@@ -10,6 +11,7 @@ export type DetectTypesProviderConfig = {
10
11
  * @returns The types provider identifier to use, or `undefined` if on cannot be
11
12
  * determined.
12
13
  */
13
- export declare const detectTypesProvider: (config?: DetectTypesProviderConfig) => Promise<TypesProvider | undefined>;
14
+ declare const detectTypesProvider: (config?: DetectTypesProviderConfig) => Promise<TypesProvider | undefined>;
14
15
  //#endregion
16
+ export { DetectTypesProviderConfig, detectTypesProvider };
15
17
  //# sourceMappingURL=detectTypesProvider.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectTypesProvider.d.mts","names":[],"sources":["../src/detectTypesProvider.ts"],"mappings":";;YAIY;EACX;;;;;;;;;qBAUY,sBAAmB,SACvB,8BACN,QAAQ"}
1
+ {"version":3,"file":"detectTypesProvider.d.mts","names":[],"sources":["../src/detectTypesProvider.ts"],"mappings":";;;KAIY,yBAAA;EACX,GAAA;AAAA;;;;;AAUD;;;cAAa,mBAAA,GACZ,MAAA,GAAQ,yBAAA,KACN,OAAA,CAAQ,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"detectTypesProvider.mjs","names":[],"sources":["../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (Number.parseInt(require(\"@prismicio/client/package.json\").version.split(\".\")[0]) >= 7) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,sBAAsB,OAClC,SAAoC,CAAC,MACG;CACxC,MAAM,MAAM,OAAO,OAAO,QAAQ,IAAI;CAEtC,MAAM,UAAU,cAAc,IAAI,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG;CAEjE,IAAI;EACH,IAAI,OAAO,SAAS,QAAQ,gCAAgC,CAAC,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,GACvF,OAAO;CAET,QAAQ,CAER;CAEA,IAAI;EACH,QAAQ,QAAQ,kBAAkB;EAElC,OAAO;CACR,QAAQ,CAER;AACD"}
1
+ {"version":3,"file":"detectTypesProvider.mjs","names":[],"sources":["../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (Number.parseInt(require(\"@prismicio/client/package.json\").version.split(\".\")[0]) >= 7) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,sBAAsB,OAClC,SAAoC,EAAE,KACE;CACxC,MAAM,MAAM,OAAO,OAAO,QAAQ,KAAK;CAEvC,MAAM,UAAU,cAAc,IAAI,SAAS,IAAI,GAAG,MAAM,MAAM,IAAI;AAElE,KAAI;AACH,MAAI,OAAO,SAAS,QAAQ,iCAAiC,CAAC,QAAQ,MAAM,IAAI,CAAC,GAAG,IAAI,EACvF,QAAO;SAED;AAIR,KAAI;AACH,UAAQ,QAAQ,mBAAmB;AAEnC,SAAO;SACA"}
@@ -1,8 +1,9 @@
1
1
  import { FieldConfigs } from "./types.mjs";
2
2
  import { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
3
+
3
4
  //#region src/generateTypes.d.ts
4
- export type TypesProvider = "@prismicio/client" | "@prismicio/types";
5
- export type GenerateTypesConfig = {
5
+ type TypesProvider = "@prismicio/client" | "@prismicio/types";
6
+ type GenerateTypesConfig = {
6
7
  customTypeModels?: CustomTypeModel[];
7
8
  sharedSliceModels?: SharedSliceModel[];
8
9
  localeIDs?: string[];
@@ -14,6 +15,7 @@ export type GenerateTypesConfig = {
14
15
  };
15
16
  cache?: boolean;
16
17
  };
17
- export declare function generateTypes(config?: GenerateTypesConfig): string;
18
+ declare function generateTypes(config?: GenerateTypesConfig): string;
18
19
  //#endregion
20
+ export { GenerateTypesConfig, TypesProvider, generateTypes };
19
21
  //# sourceMappingURL=generateTypes.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateTypes.d.mts","names":[],"sources":["../src/generateTypes.ts"],"mappings":";;;YAWY;YAIA;EACX,mBAAmB;EACnB,oBAAoB;EACpB;EACA,eAAe;EACf,gBAAgB;EAChB;IACC;IACA;;EAED;;wBAGe,cAAc,SAAQ"}
1
+ {"version":3,"file":"generateTypes.d.mts","names":[],"sources":["../src/generateTypes.ts"],"mappings":";;;;KAWY,aAAA;AAAA,KAIA,mBAAA;EACX,gBAAA,GAAmB,eAAA;EACnB,iBAAA,GAAoB,gBAAA;EACpB,SAAA;EACA,YAAA,GAAe,YAAA;EACf,aAAA,GAAgB,aAAA;EAChB,iBAAA;IACC,4BAAA;IACA,uBAAA;EAAA;EAED,KAAA;AAAA;AAAA,iBAGe,aAAA,CAAc,MAAA,GAAQ,mBAAA"}