@takeshape/schema 7.194.0

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 (312) hide show
  1. package/README.md +5 -0
  2. package/es/api-version.js +21 -0
  3. package/es/auth-schemas.js +0 -0
  4. package/es/builtin-schema.js +590 -0
  5. package/es/content-schema-transform.js +192 -0
  6. package/es/entitlements.js +0 -0
  7. package/es/enum.js +11 -0
  8. package/es/get-is-leaf.js +58 -0
  9. package/es/index.js +25 -0
  10. package/es/migration.js +413 -0
  11. package/es/mocks.js +47 -0
  12. package/es/patterns.js +0 -0
  13. package/es/project-schema/index.js +10 -0
  14. package/es/project-schema/v1.0.0.js +0 -0
  15. package/es/project-schema/v3.0.0.js +0 -0
  16. package/es/project-schema/v3.1.0.js +0 -0
  17. package/es/project-schema/v3.2.0.js +0 -0
  18. package/es/project-schema/v3.3.0.js +0 -0
  19. package/es/project-schema/v3.4.0.js +0 -0
  20. package/es/project-schema/v3.5.0.js +0 -0
  21. package/es/project-schema/v3.5.1.js +0 -0
  22. package/es/project-schema/v3.6.0.js +0 -0
  23. package/es/refs.js +301 -0
  24. package/es/resolvers.js +2 -0
  25. package/es/scalars.js +4 -0
  26. package/es/schema-util.js +1197 -0
  27. package/es/schemas/auth-schemas.json +313 -0
  28. package/es/schemas/project-schema/meta-schema-v1.0.0.json +209 -0
  29. package/es/schemas/project-schema/meta-schema-v3.0.0.json +609 -0
  30. package/es/schemas/project-schema/meta-schema-v3.1.0.json +609 -0
  31. package/es/schemas/project-schema/meta-schema-v3.2.0.json +613 -0
  32. package/es/schemas/project-schema/meta-schema-v3.3.0.json +613 -0
  33. package/es/schemas/project-schema/meta-schema-v3.4.0.json +613 -0
  34. package/es/schemas/project-schema/meta-schema-v3.5.0.json +627 -0
  35. package/es/schemas/project-schema/meta-schema-v3.5.1.json +630 -0
  36. package/es/schemas/project-schema/meta-schema-v3.6.0.json +633 -0
  37. package/es/schemas/project-schema/v1.0.0.json +321 -0
  38. package/es/schemas/project-schema/v3.0.0.json +411 -0
  39. package/es/schemas/project-schema/v3.1.0.json +569 -0
  40. package/es/schemas/project-schema/v3.2.0.json +577 -0
  41. package/es/schemas/project-schema/v3.3.0.json +578 -0
  42. package/es/schemas/project-schema/v3.4.0.json +568 -0
  43. package/es/schemas/project-schema/v3.5.0.json +568 -0
  44. package/es/schemas/project-schema/v3.5.1.json +568 -0
  45. package/es/schemas/project-schema/v3.6.0.json +584 -0
  46. package/es/schemas/project-schema.json +16 -0
  47. package/es/schemas/user-schema.json +58 -0
  48. package/es/services.js +379 -0
  49. package/es/taxonomies.js +55 -0
  50. package/es/template-shapes.js +79 -0
  51. package/es/types.js +202 -0
  52. package/es/unions.js +137 -0
  53. package/es/user-schema.js +0 -0
  54. package/es/util/detect-cycles.js +54 -0
  55. package/es/util/index.js +1 -0
  56. package/es/validate.js +764 -0
  57. package/es/versions.js +4 -0
  58. package/es/workflows.js +69 -0
  59. package/examples/.pnpm-debug.log +20 -0
  60. package/examples/v1_0_0/beer-schema.json +125 -0
  61. package/examples/v1_0_0/blog-schema.json +192 -0
  62. package/examples/v1_0_0/brewery-schema.json +232 -0
  63. package/examples/v1_0_0/complex-project-schema.json +3197 -0
  64. package/examples/v1_0_0/error-schema.json +275 -0
  65. package/examples/v1_0_0/frank-and-fred-schema.json +21387 -0
  66. package/examples/v1_0_0/massive-schema.json +6930 -0
  67. package/examples/v1_0_0/post-schema.json +83 -0
  68. package/examples/v1_0_0/real-world-schema.json +797 -0
  69. package/examples/v1_0_0/recursive-repeater-schema.json +69 -0
  70. package/examples/v1_0_0/recursive-schema.json +79 -0
  71. package/examples/v1_0_0/schema-with-repeater-draftjs.json +292 -0
  72. package/examples/v1_0_0/shape-books.json +797 -0
  73. package/examples/v1_0_0/user-schema-no-required.json +84 -0
  74. package/examples/v1_0_0/user-schema-with-defaults.json +105 -0
  75. package/examples/v1_0_0/user-schema-with-obj-prop.json +92 -0
  76. package/examples/v1_0_0/user-schema.json +87 -0
  77. package/examples/v3_0_0/rick-and-morty-rest.json +62 -0
  78. package/examples/v3_0_0/shopify-lookbook.json +1172 -0
  79. package/examples/v3_0_0/shopify-store-with-widget.json +11323 -0
  80. package/examples/v3_2_0/blog-schema.json +378 -0
  81. package/examples/v3_2_0/brewery-schema.json +385 -0
  82. package/examples/v3_2_0/complex-project-schema.json +3748 -0
  83. package/examples/v3_2_0/frank-and-fred-schema.json +19217 -0
  84. package/examples/v3_2_0/massive-schema.json +6676 -0
  85. package/examples/v3_2_0/pet-oneof-array.json +323 -0
  86. package/examples/v3_2_0/post-schema.json +265 -0
  87. package/examples/v3_2_0/real-world-schema.json +970 -0
  88. package/examples/v3_2_0/recursive-repeater-schema.json +144 -0
  89. package/examples/v3_2_0/recursive-schema.json +151 -0
  90. package/examples/v3_2_0/rick-and-morty-rest.json +65 -0
  91. package/examples/v3_2_0/schema-with-repeater-draftjs.json +381 -0
  92. package/examples/v3_2_0/shape-books.json +1044 -0
  93. package/examples/v3_2_0/shopify-store-with-widget.json +11016 -0
  94. package/examples/v3_2_0/user-schema-no-required.json +174 -0
  95. package/examples/v3_2_0/user-schema-with-defaults.json +187 -0
  96. package/examples/v3_3_0/blog-schema.json +405 -0
  97. package/examples/v3_3_0/brewery-schema.json +406 -0
  98. package/examples/v3_3_0/complex-project-schema.json +4076 -0
  99. package/examples/v3_3_0/frank-and-fred-schema.json +20913 -0
  100. package/examples/v3_3_0/massive-schema.json +7309 -0
  101. package/examples/v3_3_0/pet-oneof-array.json +380 -0
  102. package/examples/v3_3_0/post-schema.json +248 -0
  103. package/examples/v3_3_0/real-world-schema.json +1046 -0
  104. package/examples/v3_3_0/recursive-repeater-schema.json +154 -0
  105. package/examples/v3_3_0/recursive-schema.json +161 -0
  106. package/examples/v3_3_0/rick-and-morty-rest.json +101 -0
  107. package/examples/v3_3_0/schema-with-repeater-draftjs.json +393 -0
  108. package/examples/v3_3_0/shape-books.json +1121 -0
  109. package/examples/v3_3_0/shopify-lookbook.json +1196 -0
  110. package/examples/v3_3_0/shopify-store-with-widget.json +11320 -0
  111. package/examples/v3_3_0/user-schema-no-required.json +185 -0
  112. package/examples/v3_3_0/user-schema-with-defaults.json +210 -0
  113. package/examples/v3_4_0/blog-schema.json +405 -0
  114. package/examples/v3_4_0/brewery-schema.json +406 -0
  115. package/examples/v3_4_0/complex-project-schema.json +4076 -0
  116. package/examples/v3_4_0/frank-and-fred-schema.json +20913 -0
  117. package/examples/v3_4_0/massive-schema.json +7309 -0
  118. package/examples/v3_4_0/pet-oneof-array.json +420 -0
  119. package/examples/v3_4_0/post-schema.json +248 -0
  120. package/examples/v3_4_0/real-world-schema.json +1046 -0
  121. package/examples/v3_4_0/recursive-repeater-schema.json +154 -0
  122. package/examples/v3_4_0/recursive-schema.json +161 -0
  123. package/examples/v3_4_0/rick-and-morty-rest.json +101 -0
  124. package/examples/v3_4_0/schema-with-repeater-draftjs.json +393 -0
  125. package/examples/v3_4_0/shape-books.json +1121 -0
  126. package/examples/v3_4_0/shopify-lookbook.json +1196 -0
  127. package/examples/v3_4_0/shopify-store-with-widget.json +11323 -0
  128. package/examples/v3_4_0/user-schema-no-required.json +185 -0
  129. package/examples/v3_4_0/user-schema-with-defaults.json +210 -0
  130. package/examples/v3_5_0/blog-schema.json +405 -0
  131. package/examples/v3_5_0/brewery-schema.json +406 -0
  132. package/examples/v3_5_0/complex-project-schema.json +4076 -0
  133. package/examples/v3_5_0/frank-and-fred-schema.json +20913 -0
  134. package/examples/v3_5_0/massive-schema.json +7309 -0
  135. package/examples/v3_5_0/pet-oneof-array.json +420 -0
  136. package/examples/v3_5_0/post-schema.json +248 -0
  137. package/examples/v3_5_0/real-world-schema.json +1046 -0
  138. package/examples/v3_5_0/recursive-repeater-schema.json +154 -0
  139. package/examples/v3_5_0/recursive-schema.json +161 -0
  140. package/examples/v3_5_0/rick-and-morty-rest.json +101 -0
  141. package/examples/v3_5_0/schema-with-repeater-draftjs.json +393 -0
  142. package/examples/v3_5_0/shape-books.json +1121 -0
  143. package/examples/v3_5_0/shopify-lookbook.json +1196 -0
  144. package/examples/v3_5_0/shopify-store-with-widget.json +12271 -0
  145. package/examples/v3_5_0/user-schema-no-required.json +185 -0
  146. package/examples/v3_5_0/user-schema-with-defaults.json +210 -0
  147. package/examples/v3_5_1/blog-schema.json +405 -0
  148. package/examples/v3_5_1/brewery-schema.json +406 -0
  149. package/examples/v3_5_1/complex-project-schema.json +4076 -0
  150. package/examples/v3_5_1/frank-and-fred-schema.json +20913 -0
  151. package/examples/v3_5_1/massive-schema.json +7309 -0
  152. package/examples/v3_5_1/pet-oneof-array.json +420 -0
  153. package/examples/v3_5_1/post-schema.json +248 -0
  154. package/examples/v3_5_1/real-world-schema.json +1046 -0
  155. package/examples/v3_5_1/recursive-repeater-schema.json +154 -0
  156. package/examples/v3_5_1/recursive-schema.json +161 -0
  157. package/examples/v3_5_1/rick-and-morty-rest.json +101 -0
  158. package/examples/v3_5_1/schema-with-repeater-draftjs.json +393 -0
  159. package/examples/v3_5_1/shape-books.json +1121 -0
  160. package/examples/v3_5_1/shopify-lookbook.json +1196 -0
  161. package/examples/v3_5_1/shopify-store-with-widget.json +12271 -0
  162. package/examples/v3_5_1/stripe-starter-resolved.json +21419 -0
  163. package/examples/v3_5_1/user-schema-no-required.json +185 -0
  164. package/examples/v3_5_1/user-schema-with-defaults.json +210 -0
  165. package/examples/v3_6_0/blog-schema.json +405 -0
  166. package/examples/v3_6_0/brewery-schema.json +406 -0
  167. package/examples/v3_6_0/complex-project-schema.json +4076 -0
  168. package/examples/v3_6_0/frank-and-fred-schema.json +20913 -0
  169. package/examples/v3_6_0/massive-schema.json +7309 -0
  170. package/examples/v3_6_0/pet-oneof-array.json +420 -0
  171. package/examples/v3_6_0/post-schema.json +248 -0
  172. package/examples/v3_6_0/real-world-schema.json +1046 -0
  173. package/examples/v3_6_0/recursive-repeater-schema.json +154 -0
  174. package/examples/v3_6_0/recursive-schema.json +161 -0
  175. package/examples/v3_6_0/rick-and-morty-rest.json +101 -0
  176. package/examples/v3_6_0/schema-with-repeater-draftjs.json +393 -0
  177. package/examples/v3_6_0/shape-books.json +1121 -0
  178. package/examples/v3_6_0/shopify-lookbook.json +1196 -0
  179. package/examples/v3_6_0/shopify-store-with-widget.json +12271 -0
  180. package/examples/v3_6_0/stripe-starter-resolved.json +21419 -0
  181. package/examples/v3_6_0/user-schema-no-required.json +185 -0
  182. package/examples/v3_6_0/user-schema-with-defaults.json +210 -0
  183. package/lib/api-version.d.ts +6 -0
  184. package/lib/api-version.d.ts.map +1 -0
  185. package/lib/api-version.js +36 -0
  186. package/lib/auth-schemas.d.ts +105 -0
  187. package/lib/auth-schemas.d.ts.map +1 -0
  188. package/lib/auth-schemas.js +1 -0
  189. package/lib/builtin-schema.d.ts +8 -0
  190. package/lib/builtin-schema.d.ts.map +1 -0
  191. package/lib/builtin-schema.js +606 -0
  192. package/lib/content-schema-transform.d.ts +41 -0
  193. package/lib/content-schema-transform.d.ts.map +1 -0
  194. package/lib/content-schema-transform.js +217 -0
  195. package/lib/entitlements.d.ts +1 -0
  196. package/lib/entitlements.d.ts.map +1 -0
  197. package/lib/entitlements.js +1 -0
  198. package/lib/enum.d.ts +3 -0
  199. package/lib/enum.d.ts.map +1 -0
  200. package/lib/enum.js +18 -0
  201. package/lib/get-is-leaf.d.ts +4 -0
  202. package/lib/get-is-leaf.d.ts.map +1 -0
  203. package/lib/get-is-leaf.js +68 -0
  204. package/lib/index.d.ts +27 -0
  205. package/lib/index.d.ts.map +1 -0
  206. package/lib/index.js +359 -0
  207. package/lib/migration.d.ts +55 -0
  208. package/lib/migration.d.ts.map +1 -0
  209. package/lib/migration.js +463 -0
  210. package/lib/mocks.d.ts +13 -0
  211. package/lib/mocks.d.ts.map +1 -0
  212. package/lib/mocks.js +61 -0
  213. package/lib/patterns.d.ts +13 -0
  214. package/lib/patterns.d.ts.map +1 -0
  215. package/lib/patterns.js +1 -0
  216. package/lib/project-schema/index.d.ts +21 -0
  217. package/lib/project-schema/index.d.ts.map +1 -0
  218. package/lib/project-schema/index.js +122 -0
  219. package/lib/project-schema/v1.0.0.d.ts +293 -0
  220. package/lib/project-schema/v1.0.0.d.ts.map +1 -0
  221. package/lib/project-schema/v1.0.0.js +1 -0
  222. package/lib/project-schema/v3.0.0.d.ts +480 -0
  223. package/lib/project-schema/v3.0.0.d.ts.map +1 -0
  224. package/lib/project-schema/v3.0.0.js +1 -0
  225. package/lib/project-schema/v3.1.0.d.ts +623 -0
  226. package/lib/project-schema/v3.1.0.d.ts.map +1 -0
  227. package/lib/project-schema/v3.1.0.js +1 -0
  228. package/lib/project-schema/v3.2.0.d.ts +634 -0
  229. package/lib/project-schema/v3.2.0.d.ts.map +1 -0
  230. package/lib/project-schema/v3.2.0.js +1 -0
  231. package/lib/project-schema/v3.3.0.d.ts +634 -0
  232. package/lib/project-schema/v3.3.0.d.ts.map +1 -0
  233. package/lib/project-schema/v3.3.0.js +1 -0
  234. package/lib/project-schema/v3.4.0.d.ts +626 -0
  235. package/lib/project-schema/v3.4.0.d.ts.map +1 -0
  236. package/lib/project-schema/v3.4.0.js +1 -0
  237. package/lib/project-schema/v3.5.0.d.ts +651 -0
  238. package/lib/project-schema/v3.5.0.d.ts.map +1 -0
  239. package/lib/project-schema/v3.5.0.js +1 -0
  240. package/lib/project-schema/v3.5.1.d.ts +651 -0
  241. package/lib/project-schema/v3.5.1.d.ts.map +1 -0
  242. package/lib/project-schema/v3.5.1.js +1 -0
  243. package/lib/project-schema/v3.6.0.d.ts +660 -0
  244. package/lib/project-schema/v3.6.0.d.ts.map +1 -0
  245. package/lib/project-schema/v3.6.0.js +1 -0
  246. package/lib/refs.d.ts +122 -0
  247. package/lib/refs.d.ts.map +1 -0
  248. package/lib/refs.js +359 -0
  249. package/lib/resolvers.d.ts +4 -0
  250. package/lib/resolvers.d.ts.map +1 -0
  251. package/lib/resolvers.js +10 -0
  252. package/lib/scalars.d.ts +3 -0
  253. package/lib/scalars.d.ts.map +1 -0
  254. package/lib/scalars.js +13 -0
  255. package/lib/schema-util.d.ts +201 -0
  256. package/lib/schema-util.d.ts.map +1 -0
  257. package/lib/schema-util.js +1353 -0
  258. package/lib/schemas/auth-schemas.json +313 -0
  259. package/lib/schemas/project-schema/meta-schema-v1.0.0.json +209 -0
  260. package/lib/schemas/project-schema/meta-schema-v3.0.0.json +609 -0
  261. package/lib/schemas/project-schema/meta-schema-v3.1.0.json +609 -0
  262. package/lib/schemas/project-schema/meta-schema-v3.2.0.json +613 -0
  263. package/lib/schemas/project-schema/meta-schema-v3.3.0.json +613 -0
  264. package/lib/schemas/project-schema/meta-schema-v3.4.0.json +613 -0
  265. package/lib/schemas/project-schema/meta-schema-v3.5.0.json +627 -0
  266. package/lib/schemas/project-schema/meta-schema-v3.5.1.json +630 -0
  267. package/lib/schemas/project-schema/meta-schema-v3.6.0.json +633 -0
  268. package/lib/schemas/project-schema/v1.0.0.json +321 -0
  269. package/lib/schemas/project-schema/v3.0.0.json +411 -0
  270. package/lib/schemas/project-schema/v3.1.0.json +569 -0
  271. package/lib/schemas/project-schema/v3.2.0.json +577 -0
  272. package/lib/schemas/project-schema/v3.3.0.json +578 -0
  273. package/lib/schemas/project-schema/v3.4.0.json +568 -0
  274. package/lib/schemas/project-schema/v3.5.0.json +568 -0
  275. package/lib/schemas/project-schema/v3.5.1.json +568 -0
  276. package/lib/schemas/project-schema/v3.6.0.json +584 -0
  277. package/lib/schemas/project-schema.json +16 -0
  278. package/lib/schemas/user-schema.json +58 -0
  279. package/lib/services.d.ts +71 -0
  280. package/lib/services.d.ts.map +1 -0
  281. package/lib/services.js +413 -0
  282. package/lib/taxonomies.d.ts +16 -0
  283. package/lib/taxonomies.d.ts.map +1 -0
  284. package/lib/taxonomies.js +69 -0
  285. package/lib/template-shapes.d.ts +32 -0
  286. package/lib/template-shapes.d.ts.map +1 -0
  287. package/lib/template-shapes.js +100 -0
  288. package/lib/types.d.ts +187 -0
  289. package/lib/types.d.ts.map +1 -0
  290. package/lib/types.js +289 -0
  291. package/lib/unions.d.ts +29 -0
  292. package/lib/unions.d.ts.map +1 -0
  293. package/lib/unions.js +167 -0
  294. package/lib/user-schema.d.ts +39 -0
  295. package/lib/user-schema.d.ts.map +1 -0
  296. package/lib/user-schema.js +1 -0
  297. package/lib/util/detect-cycles.d.ts +6 -0
  298. package/lib/util/detect-cycles.d.ts.map +1 -0
  299. package/lib/util/detect-cycles.js +61 -0
  300. package/lib/util/index.d.ts +2 -0
  301. package/lib/util/index.d.ts.map +1 -0
  302. package/lib/util/index.js +18 -0
  303. package/lib/validate.d.ts +49 -0
  304. package/lib/validate.d.ts.map +1 -0
  305. package/lib/validate.js +823 -0
  306. package/lib/versions.d.ts +5 -0
  307. package/lib/versions.d.ts.map +1 -0
  308. package/lib/versions.js +14 -0
  309. package/lib/workflows.d.ts +15 -0
  310. package/lib/workflows.d.ts.map +1 -0
  311. package/lib/workflows.js +92 -0
  312. package/package.json +65 -0
@@ -0,0 +1,201 @@
1
+ /// <reference types="lodash" />
2
+ import type { ProjectSchema, ContentObjectSchema, ContentSchema, FormConfig, Query, QueryMap, Shape, ShapeMap, ObjectSchema, ServiceConfig } from './project-schema';
3
+ import { Maybe } from '@takeshape/util';
4
+ import { LatestProjectSchemaWithServices, ServiceMap, ServiceInfo, SchemaWithArgs, SchemaPropertyName, SchemaPropertyNode, ProjectSchemaV3X, SchemaPath, SchemaWithRef } from './types';
5
+ import { RefItem, RefItemWithPath, ServicesShapesContext } from './refs';
6
+ export declare const SERVICE_OBJECT_PATTERN_NAME = "pattern:service-object";
7
+ export declare function isBuiltinShape(shapeName: string): boolean;
8
+ export declare function isBuiltinQuery(name: string): boolean;
9
+ export declare function isBuiltinMutation(name: string): boolean;
10
+ export declare function isBuiltinType(projectSchema: ProjectSchema, refSchema: SchemaWithRef): boolean;
11
+ export declare const schemaMetadataKeys: string[];
12
+ export declare const commonSchemaKeys: string[];
13
+ export declare const scalarSchemaKeys: string[];
14
+ export declare const objectSchemaKeys: string[];
15
+ export declare const arraySchemaKeys: string[];
16
+ export declare const multipleRelationshipSchemaKeys: string[];
17
+ export declare const nonStructuralSchemaKeys: string[];
18
+ export declare function getServiceIdFieldName(serviceFieldName: string): string;
19
+ export declare function getGeneratorVersion(generator: string): string;
20
+ export declare function getServiceInfo(projectSchema: ProjectSchema, shape: Shape): Record<string, ServiceInfo[]>;
21
+ export declare function pathBetween(fromShape: Shape, toShape: Shape, projectSchema: ProjectSchema): string[];
22
+ export declare function getShapeQueriesAndMutations(shapeList: Shape[]): {
23
+ queries: QueryMap;
24
+ mutations: QueryMap;
25
+ };
26
+ export declare function getBuiltInProperties(apiVersion?: string): Record<string, ContentSchema>;
27
+ /**
28
+ * Return all the built in property names,
29
+ */
30
+ export declare const getBuiltInPropertyNames: (apiVersion?: string) => Set<string>;
31
+ export declare function applyBuiltinPropertiesToShape(projectSchema: ProjectSchema, shape: Shape): Shape;
32
+ export declare function mergeSchemaProperties(base: ObjectSchema, overrides: ObjectSchema): ContentObjectSchema;
33
+ export declare function mergeFormProperties(base: FormConfig, overrides: FormConfig): FormConfig;
34
+ export declare function applyDefaultsToSchema(projectSchema: ProjectSchema): ProjectSchema;
35
+ /**
36
+ * Finds all relationships in the schema and returns an object indexed by shape.id that lists all of the shapes
37
+ * properties that reference it
38
+ */
39
+ export declare function findExistingRelationships(projectSchema: ProjectSchema, shapes: ShapeMap): Record<string, RelationshipEnv[]>;
40
+ export interface RelationshipEnv {
41
+ shapeId: string;
42
+ path: string[];
43
+ relatedName?: string;
44
+ }
45
+ export declare function stringifyQuerySource(providerId: string, serviceId: string): string;
46
+ export declare function parseQuerySource(source: string): {
47
+ providerId: string;
48
+ serviceId: string;
49
+ };
50
+ export declare function parseQueryResolver(resolver: string): {
51
+ providerId: string;
52
+ verb: string;
53
+ };
54
+ export declare function getShapeById(projectSchema: ProjectSchema, shapeId: string): Shape | undefined;
55
+ export declare function isModelShape(shape: Shape): boolean;
56
+ export declare function getArgsReference(projectSchema: ProjectSchemaV3X, argsSchema: SchemaWithArgs): Maybe<RefItem>;
57
+ export declare function getArgsReferenceWithPath(projectSchema: ProjectSchemaV3X, argsSchema: SchemaWithArgs, schemaPath?: SchemaPath): Maybe<RefItemWithPath>;
58
+ export declare function getArgsShapeSchema(projectSchema: ProjectSchema, argsSchema: SchemaWithArgs): Maybe<ContentObjectSchema>;
59
+ export declare function shapeToContentSchema(projectSchema: ProjectSchema, shape: Shape): ContentSchema;
60
+ export declare function projectSchemaToJSONSchema(projectSchema: ProjectSchema): {
61
+ definitions: Record<string, ContentSchema>;
62
+ };
63
+ export declare function getShapeDependencies(projectSchema: ProjectSchema, shape: Shape): string[];
64
+ interface GetRelevantShapesParams {
65
+ shapeNames?: string[];
66
+ shapeIds?: string[];
67
+ byId?: boolean;
68
+ includeDependencies?: boolean;
69
+ }
70
+ export declare function getRelevantShapes(projectSchema: ProjectSchema, params: GetRelevantShapesParams): ShapeMap;
71
+ export declare type PropertyVisitorCallback = (schema: ContentSchema, path: SchemaPath) => void;
72
+ export declare function visitSchemaProperties(schema: ContentSchema, path: Array<string | number>, callback: PropertyVisitorCallback): void;
73
+ export declare function visitShapeProperties(shapes: ShapeMap, callback: PropertyVisitorCallback): void;
74
+ export declare type RefPredicate = (ref: RefItemWithPath) => boolean;
75
+ /**
76
+ * Walk through a `ProjectSchema` and collect all the `ref`s.
77
+ */
78
+ export declare function getAllRefsInShapes(projectSchema: ProjectSchemaV3X, predicate?: RefPredicate): RefItemWithPath[];
79
+ /**
80
+ * Get all refs
81
+ */
82
+ export declare function getAllRefsInQuery(projectSchema: ProjectSchemaV3X, queryPath: string[], query: Query, predicate?: (ref: RefItemWithPath) => boolean): RefItemWithPath[];
83
+ /**
84
+ * Collect refs from `queries` or `mutations`.
85
+ */
86
+ export declare function getAllRefsInQueries(projectSchema: ProjectSchemaV3X, rootPropertyName: 'queries' | 'mutations', predicate?: RefPredicate): RefItemWithPath[];
87
+ /**
88
+ * Get all refs in a ProjectSchema
89
+ * @param predicate return true to include the ref in
90
+ */
91
+ export declare function getAllRefs(projectSchema: ProjectSchemaV3X, predicate?: RefPredicate): RefItemWithPath[];
92
+ export interface Mapping {
93
+ providerId: string;
94
+ serviceId: string;
95
+ shapeName: string;
96
+ key: string;
97
+ }
98
+ export declare function parseMapping(mapping: string): Mapping;
99
+ export declare function splitMapping(mapping: string): string[];
100
+ export declare function findMapping(schema: ContentSchema, predicate: (mappingStr: string) => boolean): string | undefined;
101
+ export declare function getFirstMapping(schema: ContentSchema): string | undefined;
102
+ export declare function getFullyQualifiedShapeName(schema: ContentSchema): string | undefined;
103
+ export declare function getKey(schema: ContentSchema): string | undefined;
104
+ export declare function getPropertyService(schema: ContentSchema): string | undefined;
105
+ export declare function emptySchema(projectId: string, dataKey: string): ProjectSchema;
106
+ export declare function getShapesById(projectSchema: ProjectSchema): ShapeMap;
107
+ /**
108
+ * Walk through the project schema and return an array of all
109
+ * referenced shape names that are in a service namespace.
110
+ *
111
+ * @param projectSchema A V3 project schema.
112
+ *
113
+ * @returns A `string` array with all the shapes that are in namespaces.
114
+ */
115
+ export declare function getAllNamespaceShapes(projectSchema: ProjectSchemaV3X): string[];
116
+ /**
117
+ * Returns a list of all shape names in a service namespace, excluding any
118
+ * that have been set directly in the project schema
119
+ *
120
+ * @todo It's unsound to discard dependencies in this way, should avoid
121
+ * collisions with aliases or similar any remote shape that collides,
122
+ * e.g., Shopify_Product -> Shopify_Product_2
123
+ *
124
+ * @param projectSchema A V3 project schema with remote service configs.
125
+ *
126
+ * @returns A `Set` of shape names.
127
+ */
128
+ export declare function getNamespacedShapeNameList(projectSchema: LatestProjectSchemaWithServices): Set<string>;
129
+ /**
130
+ * Filter the service map to return only services passing the GraphQL Service
131
+ * typeguard.
132
+ *
133
+ * @param serviceMap A service map.
134
+ *
135
+ * @returns A new map with the filtered list of services
136
+ */
137
+ export declare function filterGraphQLServiceMap(serviceMap: ServiceMap): Map<string, ServiceConfig>;
138
+ /**
139
+ * Add all referenced shape names to the refSet meant to be used as a callback to visitSchemaProperties
140
+ */
141
+ export declare function collectReferencedShapeNames(projectSchema: ProjectSchema, refSet: Set<string>): (schema: ContentSchema) => void;
142
+ /**
143
+ * Get the subset of a schema that was automatically created or should otherwise
144
+ * have special protection against editing or deleting.
145
+ */
146
+ export declare function getProtectedSchema(schema: ProjectSchema): Pick<ProjectSchema, 'shapes' | 'queries' | 'mutations'>;
147
+ /**
148
+ * Given a schema, will resolve any `allOf` or `ref` objects. This function has
149
+ * to fully resolve all refs, because attempting to extend an object schema with
150
+ * a ref property would create an invalid schema, potentially containing both
151
+ * a ref and properties.
152
+ *
153
+ * If it can't create a valid schema it returns the input.
154
+ */
155
+ export declare function dereferenceSchema(context: ServicesShapesContext, shapeOrFieldSchema: ContentObjectSchema | ContentSchema, schemaPath?: SchemaPath): ContentSchema;
156
+ export declare function dereferenceObjectSchema(context: ServicesShapesContext, shapeOrFieldSchema: ContentObjectSchema | ContentSchema, schemaPath?: SchemaPath): ObjectSchema;
157
+ /**
158
+ * Creates a schema property list chainable fn, allowing you to manipulate and
159
+ * iterate the properties in a schema.
160
+ */
161
+ export declare const createSchemaPropertyList: import("lodash").CurriedFunction2<ServicesShapesContext, ContentSchema | ContentObjectSchema, {
162
+ _propertyIterator: Map<string, ContentSchema>;
163
+ orderBy: (iteratees?: ((n: SchemaPropertyNode) => string)[], orders?: ("asc" | "desc")[]) => any;
164
+ sortWith: (comparator?: ((a: SchemaPropertyNode, b: SchemaPropertyNode) => number) | undefined) => any;
165
+ sortByNamesWithList: (comparatorArray?: string[] | undefined) => any;
166
+ filterBy: (predicate: (n: SchemaPropertyNode) => boolean) => any;
167
+ forEach: (iteratee: (n: SchemaPropertyNode) => void) => any;
168
+ getNodes: () => SchemaPropertyNode[];
169
+ getObject: () => Record<string, ContentSchema>;
170
+ getNames: () => SchemaPropertyName[];
171
+ getValues: () => ContentSchema[];
172
+ }>;
173
+ /**
174
+ * Creates a schema property accessor, allowing you to safely access schema
175
+ * properties.
176
+ */
177
+ export declare const createSchemaPropertyAccessor: import("lodash").CurriedFunction2<ServicesShapesContext, ContentSchema | ContentObjectSchema, {
178
+ getValue: (propertyName: SchemaPropertyName) => Maybe<ContentSchema>;
179
+ findValue: (predicate: (n: SchemaPropertyNode) => boolean) => Maybe<ContentSchema>;
180
+ findName: (predicate: (n: SchemaPropertyNode) => boolean) => Maybe<SchemaPropertyName>;
181
+ getKey: (propertyName: SchemaPropertyName) => Maybe<string>;
182
+ }>;
183
+ /**
184
+ * Find the query in the schema that corresponds to the given shape and resolver.
185
+ */
186
+ export declare const findQuery: (projectSchema: ProjectSchema, shapeName: string, resolver: string) => string;
187
+ /**
188
+ * Find the query in the schema that corresponds to the given shape and resolver.
189
+ */
190
+ export declare const findMutation: (projectSchema: ProjectSchema, shapeName: string, resolver: string) => string;
191
+ /**
192
+ * Find the form config for a given shape name and the form key.
193
+ */
194
+ export declare function findShapeFormConfig(projectSchema: ProjectSchema, shapeName: string, formName: string): Maybe<FormConfig>;
195
+ export declare type ResolverWithDefaultMutation = 'takeshape:create' | 'takeshape:update' | 'takeshape:delete' | 'takeshape:duplicate';
196
+ /**
197
+ * Find the query in the schema that corresponds to the given shape and resolver.
198
+ */
199
+ export declare const getDefaultMutationName: (shapeName: string, resolver: ResolverWithDefaultMutation) => string;
200
+ export {};
201
+ //# sourceMappingURL=schema-util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-util.d.ts","sourceRoot":"","sources":["../../src/schema-util.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,UAAU,EAEV,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EAAC,KAAK,EAAuB,MAAM,iBAAiB,CAAC;AAO5D,OAAO,EACL,+BAA+B,EAC/B,UAAU,EACV,WAAW,EAEX,cAAc,EAOd,kBAAkB,EAClB,kBAAkB,EAGlB,gBAAgB,EAChB,UAAU,EAC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