@powerhousedao/builder-tools 0.2.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 (189) hide show
  1. package/dist/connect-studio/helpers.d.ts +5 -0
  2. package/dist/connect-studio/helpers.d.ts.map +1 -0
  3. package/dist/connect-studio/helpers.js +43 -0
  4. package/dist/connect-studio/hmr.d.ts +12 -0
  5. package/dist/connect-studio/hmr.d.ts.map +1 -0
  6. package/dist/connect-studio/hmr.js +8 -0
  7. package/dist/connect-studio/index.d.ts +9 -0
  8. package/dist/connect-studio/index.d.ts.map +1 -0
  9. package/dist/connect-studio/index.js +7 -0
  10. package/dist/connect-studio/server.d.ts +3 -0
  11. package/dist/connect-studio/server.d.ts.map +1 -0
  12. package/dist/connect-studio/server.js +175 -0
  13. package/dist/connect-studio/studio.d.ts +3 -0
  14. package/dist/connect-studio/studio.d.ts.map +1 -0
  15. package/dist/connect-studio/studio.js +65 -0
  16. package/dist/connect-studio/types.d.ts +25 -0
  17. package/dist/connect-studio/types.d.ts.map +1 -0
  18. package/dist/connect-studio/types.js +1 -0
  19. package/dist/connect-studio/vite-plugins/base.d.ts +19 -0
  20. package/dist/connect-studio/vite-plugins/base.d.ts.map +1 -0
  21. package/dist/connect-studio/vite-plugins/base.js +162 -0
  22. package/dist/connect-studio/vite-plugins/external-packages.d.ts +6 -0
  23. package/dist/connect-studio/vite-plugins/external-packages.d.ts.map +1 -0
  24. package/dist/connect-studio/vite-plugins/external-packages.js +74 -0
  25. package/dist/connect-studio/vite-plugins/hmr.d.ts +3 -0
  26. package/dist/connect-studio/vite-plugins/hmr.d.ts.map +1 -0
  27. package/dist/connect-studio/vite-plugins/hmr.js +57 -0
  28. package/dist/connect-studio/vite-plugins/importmap.d.ts +20 -0
  29. package/dist/connect-studio/vite-plugins/importmap.d.ts.map +1 -0
  30. package/dist/connect-studio/vite-plugins/importmap.js +174 -0
  31. package/dist/connect-studio/vite-plugins/studio.d.ts +4 -0
  32. package/dist/connect-studio/vite-plugins/studio.d.ts.map +1 -0
  33. package/dist/connect-studio/vite-plugins/studio.js +112 -0
  34. package/dist/document-model-editor/components/button.d.ts +4 -0
  35. package/dist/document-model-editor/components/button.d.ts.map +1 -0
  36. package/dist/document-model-editor/components/button.js +7 -0
  37. package/dist/document-model-editor/components/code-editors/graphql-editor.d.ts +10 -0
  38. package/dist/document-model-editor/components/code-editors/graphql-editor.d.ts.map +1 -0
  39. package/dist/document-model-editor/components/code-editors/graphql-editor.js +75 -0
  40. package/dist/document-model-editor/components/code-editors/json-editor.d.ts +8 -0
  41. package/dist/document-model-editor/components/code-editors/json-editor.d.ts.map +1 -0
  42. package/dist/document-model-editor/components/code-editors/json-editor.js +43 -0
  43. package/dist/document-model-editor/components/code-editors/utils.d.ts +32 -0
  44. package/dist/document-model-editor/components/code-editors/utils.d.ts.map +1 -0
  45. package/dist/document-model-editor/components/code-editors/utils.js +191 -0
  46. package/dist/document-model-editor/components/divider.d.ts +8 -0
  47. package/dist/document-model-editor/components/divider.d.ts.map +1 -0
  48. package/dist/document-model-editor/components/divider.js +21 -0
  49. package/dist/document-model-editor/components/errors.d.ts +6 -0
  50. package/dist/document-model-editor/components/errors.d.ts.map +1 -0
  51. package/dist/document-model-editor/components/errors.js +4 -0
  52. package/dist/document-model-editor/components/form.d.ts +12 -0
  53. package/dist/document-model-editor/components/form.d.ts.map +1 -0
  54. package/dist/document-model-editor/components/form.js +42 -0
  55. package/dist/document-model-editor/components/input.d.ts +6 -0
  56. package/dist/document-model-editor/components/input.d.ts.map +1 -0
  57. package/dist/document-model-editor/components/input.js +8 -0
  58. package/dist/document-model-editor/components/label.d.ts +6 -0
  59. package/dist/document-model-editor/components/label.d.ts.map +1 -0
  60. package/dist/document-model-editor/components/label.js +9 -0
  61. package/dist/document-model-editor/components/model-metadata-form.d.ts +45 -0
  62. package/dist/document-model-editor/components/model-metadata-form.d.ts.map +1 -0
  63. package/dist/document-model-editor/components/model-metadata-form.js +69 -0
  64. package/dist/document-model-editor/components/module-form.d.ts +10 -0
  65. package/dist/document-model-editor/components/module-form.d.ts.map +1 -0
  66. package/dist/document-model-editor/components/module-form.js +21 -0
  67. package/dist/document-model-editor/components/module.d.ts +21 -0
  68. package/dist/document-model-editor/components/module.d.ts.map +1 -0
  69. package/dist/document-model-editor/components/module.js +9 -0
  70. package/dist/document-model-editor/components/modules.d.ts +19 -0
  71. package/dist/document-model-editor/components/modules.d.ts.map +1 -0
  72. package/dist/document-model-editor/components/modules.js +16 -0
  73. package/dist/document-model-editor/components/operation-description-form.d.ts +9 -0
  74. package/dist/document-model-editor/components/operation-description-form.d.ts.map +1 -0
  75. package/dist/document-model-editor/components/operation-description-form.js +12 -0
  76. package/dist/document-model-editor/components/operation-error-form.d.ts +13 -0
  77. package/dist/document-model-editor/components/operation-error-form.d.ts.map +1 -0
  78. package/dist/document-model-editor/components/operation-error-form.js +39 -0
  79. package/dist/document-model-editor/components/operation-errors.d.ts +10 -0
  80. package/dist/document-model-editor/components/operation-errors.d.ts.map +1 -0
  81. package/dist/document-model-editor/components/operation-errors.js +16 -0
  82. package/dist/document-model-editor/components/operation-form.d.ts +13 -0
  83. package/dist/document-model-editor/components/operation-form.d.ts.map +1 -0
  84. package/dist/document-model-editor/components/operation-form.js +36 -0
  85. package/dist/document-model-editor/components/operation.d.ts +22 -0
  86. package/dist/document-model-editor/components/operation.d.ts.map +1 -0
  87. package/dist/document-model-editor/components/operation.js +21 -0
  88. package/dist/document-model-editor/components/operations.d.ts +17 -0
  89. package/dist/document-model-editor/components/operations.d.ts.map +1 -0
  90. package/dist/document-model-editor/components/operations.js +19 -0
  91. package/dist/document-model-editor/components/state-schemas.d.ts +13 -0
  92. package/dist/document-model-editor/components/state-schemas.d.ts.map +1 -0
  93. package/dist/document-model-editor/components/state-schemas.js +34 -0
  94. package/dist/document-model-editor/components/tabs.d.ts +8 -0
  95. package/dist/document-model-editor/components/tabs.d.ts.map +1 -0
  96. package/dist/document-model-editor/components/tabs.js +12 -0
  97. package/dist/document-model-editor/components/text-area.d.ts +9 -0
  98. package/dist/document-model-editor/components/text-area.d.ts.map +1 -0
  99. package/dist/document-model-editor/components/text-area.js +26 -0
  100. package/dist/document-model-editor/components/text-field.d.ts +21 -0
  101. package/dist/document-model-editor/components/text-field.d.ts.map +1 -0
  102. package/dist/document-model-editor/components/text-field.js +78 -0
  103. package/dist/document-model-editor/constants/documents.d.ts +12 -0
  104. package/dist/document-model-editor/constants/documents.d.ts.map +1 -0
  105. package/dist/document-model-editor/constants/documents.js +16 -0
  106. package/dist/document-model-editor/context/form-context.d.ts +11 -0
  107. package/dist/document-model-editor/context/form-context.d.ts.map +1 -0
  108. package/dist/document-model-editor/context/form-context.js +3 -0
  109. package/dist/document-model-editor/context/schema-context.d.ts +11 -0
  110. package/dist/document-model-editor/context/schema-context.d.ts.map +1 -0
  111. package/dist/document-model-editor/context/schema-context.js +116 -0
  112. package/dist/document-model-editor/document-model-editor.stories.d.ts +48 -0
  113. package/dist/document-model-editor/document-model-editor.stories.d.ts.map +1 -0
  114. package/dist/document-model-editor/document-model-editor.stories.js +252 -0
  115. package/dist/document-model-editor/editor.d.ts +3 -0
  116. package/dist/document-model-editor/editor.d.ts.map +1 -0
  117. package/dist/document-model-editor/editor.js +186 -0
  118. package/dist/document-model-editor/hooks/useFormField.d.ts +13 -0
  119. package/dist/document-model-editor/hooks/useFormField.d.ts.map +1 -0
  120. package/dist/document-model-editor/hooks/useFormField.js +21 -0
  121. package/dist/document-model-editor/index.d.ts +3 -0
  122. package/dist/document-model-editor/index.d.ts.map +1 -0
  123. package/dist/document-model-editor/index.js +2 -0
  124. package/dist/document-model-editor/module.d.ts +4 -0
  125. package/dist/document-model-editor/module.d.ts.map +1 -0
  126. package/dist/document-model-editor/module.js +10 -0
  127. package/dist/document-model-editor/schemas/inputs.d.ts +31 -0
  128. package/dist/document-model-editor/schemas/inputs.d.ts.map +1 -0
  129. package/dist/document-model-editor/schemas/inputs.js +70 -0
  130. package/dist/document-model-editor/schemas/utils.d.ts +3 -0
  131. package/dist/document-model-editor/schemas/utils.d.ts.map +1 -0
  132. package/dist/document-model-editor/schemas/utils.js +2 -0
  133. package/dist/document-model-editor/types/documents.d.ts +27 -0
  134. package/dist/document-model-editor/types/documents.d.ts.map +1 -0
  135. package/dist/document-model-editor/types/documents.js +1 -0
  136. package/dist/document-model-editor/utils/helpers.d.ts +39 -0
  137. package/dist/document-model-editor/utils/helpers.d.ts.map +1 -0
  138. package/dist/document-model-editor/utils/helpers.js +293 -0
  139. package/dist/document-model-editor/utils/linting.d.ts +7 -0
  140. package/dist/document-model-editor/utils/linting.d.ts.map +1 -0
  141. package/dist/document-model-editor/utils/linting.js +47 -0
  142. package/dist/document-model-editor/utils/style.d.ts +3 -0
  143. package/dist/document-model-editor/utils/style.d.ts.map +1 -0
  144. package/dist/document-model-editor/utils/style.js +5 -0
  145. package/dist/editor-utils/components/documentEditor.d.ts +7 -0
  146. package/dist/editor-utils/components/documentEditor.d.ts.map +1 -0
  147. package/dist/editor-utils/components/documentEditor.js +5 -0
  148. package/dist/editor-utils/components/editorToolbar.d.ts +11 -0
  149. package/dist/editor-utils/components/editorToolbar.d.ts.map +1 -0
  150. package/dist/editor-utils/components/editorToolbar.js +5 -0
  151. package/dist/editor-utils/components/editorWorksheet.d.ts +7 -0
  152. package/dist/editor-utils/components/editorWorksheet.d.ts.map +1 -0
  153. package/dist/editor-utils/components/editorWorksheet.js +4 -0
  154. package/dist/editor-utils/components/index.d.ts +9 -0
  155. package/dist/editor-utils/components/index.d.ts.map +1 -0
  156. package/dist/editor-utils/components/index.js +9 -0
  157. package/dist/editor-utils/components/styles.d.ts +40 -0
  158. package/dist/editor-utils/components/styles.d.ts.map +1 -0
  159. package/dist/editor-utils/components/styles.js +78 -0
  160. package/dist/editor-utils/components/stylesVariant.d.ts +40 -0
  161. package/dist/editor-utils/components/stylesVariant.d.ts.map +1 -0
  162. package/dist/editor-utils/components/stylesVariant.js +88 -0
  163. package/dist/editor-utils/components/textInput.d.ts +20 -0
  164. package/dist/editor-utils/components/textInput.d.ts.map +1 -0
  165. package/dist/editor-utils/components/textInput.js +83 -0
  166. package/dist/editor-utils/components/textInputVariant.d.ts +21 -0
  167. package/dist/editor-utils/components/textInputVariant.d.ts.map +1 -0
  168. package/dist/editor-utils/components/textInputVariant.js +92 -0
  169. package/dist/editor-utils/components/toolbarButton.d.ts +7 -0
  170. package/dist/editor-utils/components/toolbarButton.d.ts.map +1 -0
  171. package/dist/editor-utils/components/toolbarButton.js +8 -0
  172. package/dist/editor-utils/hooks/index.d.ts +2 -0
  173. package/dist/editor-utils/hooks/index.d.ts.map +1 -0
  174. package/dist/editor-utils/hooks/index.js +1 -0
  175. package/dist/editor-utils/hooks/useEnsInfo.d.ts +15 -0
  176. package/dist/editor-utils/hooks/useEnsInfo.d.ts.map +1 -0
  177. package/dist/editor-utils/hooks/useEnsInfo.js +63 -0
  178. package/dist/editor-utils/index.d.ts +5 -0
  179. package/dist/editor-utils/index.d.ts.map +1 -0
  180. package/dist/editor-utils/index.js +4 -0
  181. package/dist/editor-utils/reducer.d.ts +3 -0
  182. package/dist/editor-utils/reducer.d.ts.map +1 -0
  183. package/dist/editor-utils/reducer.js +24 -0
  184. package/dist/editor-utils/storybook.d.ts +25 -0
  185. package/dist/editor-utils/storybook.d.ts.map +1 -0
  186. package/dist/editor-utils/storybook.js +118 -0
  187. package/dist/styles.css +786 -0
  188. package/dist/tsconfig.tsbuildinfo +1 -0
  189. package/package.json +102 -0
@@ -0,0 +1,2 @@
1
+ export { DocumentModelEditor } from "./editor.js";
2
+ export { documentModelEditorModule } from "./module.js";
@@ -0,0 +1,4 @@
1
+ import type { DocumentModelDocument } from "document-model";
2
+ import { EditorModule } from "document-model";
3
+ export declare const documentModelEditorModule: EditorModule<DocumentModelDocument>;
4
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../document-model-editor/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,yBAAyB,EAAE,YAAY,CAAC,qBAAqB,CAQzE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { DocumentModelEditor } from "./editor.js";
2
+ export const documentModelEditorModule = {
3
+ Component: DocumentModelEditor,
4
+ documentTypes: ["powerhouse/document-model"],
5
+ config: {
6
+ id: "document-model-editor-v2",
7
+ disableExternalControls: true,
8
+ documentToolbarEnabled: true,
9
+ },
10
+ };
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ export declare function containsSpaces(s: string): boolean;
3
+ export declare function replaceSpaces(s: string): string;
4
+ type SchemaOptions = {
5
+ required?: boolean;
6
+ allowEmpty?: boolean;
7
+ unique?: string[];
8
+ };
9
+ export declare function createNameSchema(options?: SchemaOptions): z.ZodString | z.ZodEffects<z.ZodString, string, string> | z.ZodOptional<z.ZodString> | z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
10
+ export declare function createConstantCaseSchema(options?: SchemaOptions): z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>, string | undefined, string | undefined> | z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>, string | undefined, string | undefined>, string | undefined, string | undefined> | z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string | undefined, string>, string | undefined, string> | z.ZodEffects<z.ZodEffects<z.ZodString, string | undefined, string>, string | undefined, string>;
11
+ export declare function createLowercaseSnakeCaseSchema(options?: SchemaOptions): z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>, string | undefined, string | undefined> | z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>, string | undefined, string | undefined>, string | undefined, string | undefined> | z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string | undefined, string>, string | undefined, string> | z.ZodEffects<z.ZodEffects<z.ZodString, string | undefined, string>, string | undefined, string>;
12
+ export declare function toLowercaseSnakeCase(value: string, options?: SchemaOptions): LowercaseSnakeCase;
13
+ export declare function toConstantCase(value: string, options?: SchemaOptions): ConstantCase;
14
+ export type SnakeCase = `${string}_${string}`;
15
+ export type LowercaseSnakeCase = Lowercase<SnakeCase>;
16
+ export type ConstantCase = Uppercase<SnakeCase>;
17
+ export type Prettify<T> = {
18
+ [K in keyof T]: T[K];
19
+ } & {};
20
+ export declare const AuthorSchema: z.ZodDefault<z.ZodObject<{
21
+ name: z.ZodString | z.ZodEffects<z.ZodString, string, string> | z.ZodOptional<z.ZodString> | z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
22
+ website: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"">]>>>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ website: string;
25
+ name?: string | undefined;
26
+ }, {
27
+ name?: string | undefined;
28
+ website?: string | undefined;
29
+ }>>;
30
+ export {};
31
+ //# sourceMappingURL=inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../document-model-editor/schemas/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,WAEvC;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,UAEtC;AAED,KAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,aAAkB,2KAkC3D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,aAAkB,2iBAMnE;AAED,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,aAAkB,2iBAMzE;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,GAItB,kBAAkB,CACxB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAGlE,YAAY,CAClB;AAED,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAC9C,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AACtD,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AAChD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAC;AAEP,eAAO,MAAM,YAAY;;;;;;;;;GAWrB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { z } from "zod";
2
+ import validator from "validator";
3
+ import { snakeCase, constantCase } from "change-case";
4
+ const whitespaceRegex = /\s+/g;
5
+ export function containsSpaces(s) {
6
+ return whitespaceRegex.test(s);
7
+ }
8
+ export function replaceSpaces(s) {
9
+ return s.replace(whitespaceRegex, "_");
10
+ }
11
+ export function createNameSchema(options = {}) {
12
+ const { required = false, allowEmpty = false, unique = [] } = options;
13
+ const baseSchema = allowEmpty ? z.string() : z.string().min(1);
14
+ const uniqueRefinement = baseSchema.refine((value) => {
15
+ if (!value && allowEmpty)
16
+ return true;
17
+ return !unique
18
+ .map((n) => n.toLowerCase())
19
+ .includes(value.replace(/^\s+|\s+$/g, "_").toLowerCase());
20
+ }, { message: "Item with this name already exists" });
21
+ if (!required) {
22
+ return unique.length > 0
23
+ ? z
24
+ .string()
25
+ .optional()
26
+ .refine((value) => {
27
+ if (value === undefined)
28
+ return true;
29
+ if (!value && allowEmpty)
30
+ return true;
31
+ return !unique
32
+ .map((n) => n.toLowerCase())
33
+ .includes(value.replace(/^\s+|\s+$/g, "_").toLowerCase());
34
+ }, { message: "Item with this name already exists" })
35
+ : z.string().optional();
36
+ }
37
+ return unique.length > 0 ? uniqueRefinement : baseSchema;
38
+ }
39
+ export function createConstantCaseSchema(options = {}) {
40
+ return createNameSchema(options)
41
+ .transform((value) => (value ? value.toUpperCase() : value))
42
+ .refine((value) => !value || validator.isUppercase(value), {
43
+ message: "Must be uppercase",
44
+ });
45
+ }
46
+ export function createLowercaseSnakeCaseSchema(options = {}) {
47
+ return createNameSchema(options)
48
+ .transform((value) => (value ? value.toLowerCase() : value))
49
+ .refine((value) => !value || validator.isLowercase(value), {
50
+ message: "Must be lowercase",
51
+ });
52
+ }
53
+ export function toLowercaseSnakeCase(value, options = {}) {
54
+ return createLowercaseSnakeCaseSchema(options).parse(snakeCase(value));
55
+ }
56
+ export function toConstantCase(value, options = {}) {
57
+ return createConstantCaseSchema(options).parse(constantCase(value));
58
+ }
59
+ export const AuthorSchema = z
60
+ .object({
61
+ name: createNameSchema({ allowEmpty: true }),
62
+ website: z
63
+ .union([z.string().url(), z.literal("")])
64
+ .optional()
65
+ .default(""),
66
+ })
67
+ .default({
68
+ name: "",
69
+ website: "",
70
+ });
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ export declare const EmptyStringSchema: z.ZodDefault<z.ZodString>;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../document-model-editor/schemas/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB,2BAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { z } from "zod";
2
+ export const EmptyStringSchema = z.string().default("");
@@ -0,0 +1,27 @@
1
+ import { OperationScope } from "document-model";
2
+ export type Scope = OperationScope;
3
+ export type DocumentActionHandlers = {
4
+ addModule: (name: string) => Promise<string | undefined>;
5
+ addOperation: (moduleId: string, name: string) => Promise<string | undefined>;
6
+ addOperationAndInitialSchema: (moduleId: string, name: string) => Promise<string | undefined>;
7
+ addOperationError: (operationId: string, errorName: string) => Promise<string | undefined>;
8
+ setModelId: (id: string) => void;
9
+ setModelExtension: (extension: string) => void;
10
+ setModelName: (name: string) => void;
11
+ setAuthorName: (authorName: string) => void;
12
+ setAuthorWebsite: (authorWebsite: string) => void;
13
+ setStateSchema: (schema: string, scope: Scope) => void;
14
+ setInitialState: (initialValue: string, scope: Scope) => void;
15
+ setModelDescription: (description: string) => void;
16
+ updateModuleName: (id: string, name: string) => void;
17
+ updateModuleDescription: (id: string, description: string) => void;
18
+ deleteModule: (id: string) => void;
19
+ updateOperationName: (id: string, name: string) => void;
20
+ updateOperationSchema: (id: string, schema: string) => void;
21
+ updateOperationScope: (id: string, scope: Scope) => void;
22
+ setOperationDescription: (id: string, description: string) => void;
23
+ deleteOperation: (id: string) => void;
24
+ deleteOperationError: (id: string) => void;
25
+ setOperationErrorName: (operationId: string, errorId: string, errorName: string) => void;
26
+ };
27
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../document-model-editor/types/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,KAAK,GAAG,cAAc,CAAC;AAEnC,MAAM,MAAM,sBAAsB,GAAG;IAEnC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACzD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9E,4BAA4B,EAAE,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjC,iBAAiB,EAAE,CACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAGjC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvD,eAAe,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9D,mBAAmB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,qBAAqB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,oBAAoB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzD,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,oBAAoB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,qBAAqB,EAAE,CACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,KACd,IAAI,CAAC;CACX,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import { Author, DocumentModelDocument } from "document-model";
2
+ import { Scope } from "../types/documents.js";
3
+ export declare function makeStateObject(modelName: string, scope: Scope): string;
4
+ export declare function makeEmptyInputObject(name: string): string;
5
+ export declare function makeOperationInputName(operationName: string): string;
6
+ export declare function makeStateObjectName(modelName: string, scope: string): string;
7
+ export declare function makeOperationInitialDoc(name: string): string;
8
+ export declare function makeInitialSchemaDoc(modelName: string, scope: Scope): string;
9
+ export declare function makeSchemaStringFromDocs(docs: Record<string, string>): string;
10
+ export declare function getDocumentMetadata(document: DocumentModelDocument): {
11
+ name: string;
12
+ documentType: string;
13
+ description: string;
14
+ extension: string;
15
+ author: Author;
16
+ };
17
+ export declare function getDifferences<T extends object>(obj1: T | undefined | null, obj2: Partial<T> | undefined | null): Partial<T>;
18
+ export declare function makeMinimalObjectFromSDL(schemaSdl: string, sdl: string, existingValue?: any): string;
19
+ export declare function compareStringsWithoutWhitespace(str1: string | null | undefined, str2: string | null | undefined): boolean;
20
+ export declare function renameSchemaType(sdl: string, oldName: string, newName: string, scope: Scope): string;
21
+ export declare function initializeModelSchema(params: {
22
+ modelName: string;
23
+ setStateSchema: (schema: string, scope: Scope) => void;
24
+ }): void;
25
+ export declare function updateModelSchemaNames(params: {
26
+ oldName: string;
27
+ newName: string;
28
+ globalStateSchema: string;
29
+ localStateSchema: string;
30
+ setStateSchema: (schema: string, scope: Scope) => void;
31
+ }): void;
32
+ export declare function handleModelNameChange(params: {
33
+ oldName: string;
34
+ newName: string;
35
+ globalStateSchema: string;
36
+ localStateSchema: string;
37
+ setStateSchema: (schema: string, scope: Scope) => void;
38
+ }): void;
39
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../document-model-editor/utils/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAmB/D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UA0B9D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAyBhD;AAED,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,UAE3D;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAEnE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,UAInD;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAGnE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAEpE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB;;;;;;EAalE;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,IAAI,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EAC1B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAClC,OAAO,CAAC,CAAC,CAAC,CAmDZ;AAoGD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,aAAa,CAAC,EAAE,GAAG,UAuCpB;AAMD,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,WAUhC;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,GACX,MAAM,CAsBR;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACxD,QAIA;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACxD,QA0BA;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACxD,QAWA"}
@@ -0,0 +1,293 @@
1
+ import * as customScalars from "@powerhousedao/scalars";
2
+ import { pascalCase } from "change-case";
3
+ import { buildASTSchema, extendSchema, getNullableType, GraphQLScalarType, isEnumType, isListType, isObjectType, isScalarType, Kind, parse, print, visit, } from "graphql";
4
+ export function makeStateObject(modelName, scope) {
5
+ const name = makeStateObjectName(modelName, scope);
6
+ const inputNode = {
7
+ kind: Kind.OBJECT_TYPE_DEFINITION,
8
+ name: {
9
+ kind: Kind.NAME,
10
+ value: name,
11
+ },
12
+ fields: [
13
+ {
14
+ description: {
15
+ kind: Kind.STRING,
16
+ value: `Add your ${scope} state fields here`,
17
+ block: false,
18
+ },
19
+ kind: Kind.FIELD_DEFINITION,
20
+ name: { kind: Kind.NAME, value: "_placeholder" },
21
+ type: {
22
+ kind: Kind.NAMED_TYPE,
23
+ name: { kind: Kind.NAME, value: "String" },
24
+ },
25
+ },
26
+ ],
27
+ };
28
+ return print(inputNode);
29
+ }
30
+ export function makeEmptyInputObject(name) {
31
+ const inputNode = {
32
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
33
+ name: {
34
+ kind: Kind.NAME,
35
+ value: name,
36
+ },
37
+ fields: [
38
+ {
39
+ description: {
40
+ kind: Kind.STRING,
41
+ value: "Add your inputs here",
42
+ block: false,
43
+ },
44
+ kind: Kind.INPUT_VALUE_DEFINITION,
45
+ name: { kind: Kind.NAME, value: "_placeholder" },
46
+ type: {
47
+ kind: Kind.NAMED_TYPE,
48
+ name: { kind: Kind.NAME, value: "String" },
49
+ },
50
+ },
51
+ ],
52
+ };
53
+ return print(inputNode);
54
+ }
55
+ export function makeOperationInputName(operationName) {
56
+ return `${pascalCase(operationName)}Input`;
57
+ }
58
+ export function makeStateObjectName(modelName, scope) {
59
+ return `${pascalCase(modelName)}${scope === "local" ? "Local" : ""}State`;
60
+ }
61
+ export function makeOperationInitialDoc(name) {
62
+ const inputName = makeOperationInputName(name);
63
+ const inputObject = makeEmptyInputObject(inputName);
64
+ return inputObject;
65
+ }
66
+ export function makeInitialSchemaDoc(modelName, scope) {
67
+ const stateObject = makeStateObject(modelName, scope);
68
+ return stateObject;
69
+ }
70
+ export function makeSchemaStringFromDocs(docs) {
71
+ return Object.values(docs).join("\n");
72
+ }
73
+ export function getDocumentMetadata(document) {
74
+ const globalState = document.state.global;
75
+ const author = {
76
+ name: globalState.author.name,
77
+ website: globalState.author.website,
78
+ };
79
+ return {
80
+ name: globalState.name,
81
+ documentType: globalState.id,
82
+ description: globalState.description,
83
+ extension: globalState.extension,
84
+ author,
85
+ };
86
+ }
87
+ export function getDifferences(obj1, obj2) {
88
+ if (!obj1 || !obj2)
89
+ return {};
90
+ const differences = {};
91
+ function isObject(value) {
92
+ return !!value && typeof value === "object" && !Array.isArray(value);
93
+ }
94
+ const compare = (value1, value2) => {
95
+ if (isObject(value1) && isObject(value2)) {
96
+ // Convert both objects to JSON strings to compare them as a whole.
97
+ const keys1 = Object.keys(value1).sort();
98
+ const keys2 = Object.keys(value2).sort();
99
+ if (JSON.stringify(keys1) !== JSON.stringify(keys2) ||
100
+ keys1.some((key) => compare(value1[key], value2[key]))) {
101
+ return true; // Any difference in object structure or value means they're different.
102
+ }
103
+ return false;
104
+ }
105
+ else if (Array.isArray(value1) && Array.isArray(value2)) {
106
+ // For arrays, compare their serialized forms.
107
+ return JSON.stringify(value1) !== JSON.stringify(value2);
108
+ }
109
+ else {
110
+ // For primitives, compare directly.
111
+ return value1 !== value2;
112
+ }
113
+ };
114
+ for (const key of new Set([...Object.keys(obj1), ...Object.keys(obj2)])) {
115
+ if (compare(obj1[key], obj2[key])) {
116
+ differences[key] =
117
+ obj2[key];
118
+ }
119
+ }
120
+ return Object.entries(differences).reduce((acc, [key, value]) => {
121
+ if (value !== undefined) {
122
+ // @ts-expect-error generic cannot be inferred
123
+ acc[key] = value;
124
+ }
125
+ return acc;
126
+ }, {});
127
+ }
128
+ function isValidScalarValue(typeName, value) {
129
+ if (typeName in customScalars) {
130
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
131
+ const scalar = customScalars[typeName];
132
+ if (scalar instanceof GraphQLScalarType) {
133
+ return scalar.parseValue(value) !== undefined;
134
+ }
135
+ }
136
+ switch (typeName) {
137
+ case "Int":
138
+ return Number.isInteger(value);
139
+ case "Float":
140
+ return typeof value === "number";
141
+ case "Boolean":
142
+ return typeof value === "boolean";
143
+ case "DateTime":
144
+ return typeof value === "string" && !isNaN(Date.parse(value));
145
+ case "ID":
146
+ case "String":
147
+ default:
148
+ return typeof value === "string";
149
+ }
150
+ }
151
+ function getMinimalValue(type, schema, existingValue) {
152
+ const nullableType = getNullableType(type);
153
+ if (isScalarType(nullableType)) {
154
+ const typeName = nullableType.name;
155
+ if (existingValue !== undefined &&
156
+ isValidScalarValue(typeName, existingValue)) {
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
158
+ return existingValue;
159
+ }
160
+ switch (typeName) {
161
+ case "Int":
162
+ case "Float":
163
+ return 0;
164
+ case "Boolean":
165
+ return false;
166
+ case "DateTime":
167
+ return new Date().toISOString();
168
+ case "ID":
169
+ case "String":
170
+ default:
171
+ return ""; // Return empty string for custom scalars and String/ID types
172
+ }
173
+ }
174
+ if (isEnumType(nullableType)) {
175
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
176
+ const enumValues = nullableType.getValues().map((v) => v.value);
177
+ if (existingValue !== undefined && enumValues.includes(existingValue)) {
178
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
179
+ return existingValue;
180
+ }
181
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
182
+ return enumValues[0] || null;
183
+ }
184
+ if (isListType(nullableType)) {
185
+ if (existingValue !== undefined && Array.isArray(existingValue)) {
186
+ // Optionally, validate each element in the array
187
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
188
+ return existingValue;
189
+ }
190
+ return [];
191
+ }
192
+ if (isObjectType(nullableType)) {
193
+ const result = {};
194
+ const fields = nullableType.getFields();
195
+ const _existingValue = existingValue;
196
+ for (const fieldName in fields) {
197
+ const field = fields[fieldName];
198
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
199
+ const existingFieldValue = _existingValue
200
+ ? _existingValue[fieldName]
201
+ : undefined;
202
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
203
+ result[fieldName] = getMinimalValue(field.type, schema, existingFieldValue);
204
+ }
205
+ return result;
206
+ }
207
+ // Handle other types like InterfaceType, UnionType as needed
208
+ return null;
209
+ }
210
+ export function makeMinimalObjectFromSDL(schemaSdl, sdl, existingValue) {
211
+ const schema = buildASTSchema(parse(schemaSdl));
212
+ const typeAST = parse(sdl);
213
+ // Extract the type names from the SDL
214
+ const typeNames = [];
215
+ typeAST.definitions.forEach((def) => {
216
+ if (def.kind === Kind.OBJECT_TYPE_DEFINITION ||
217
+ def.kind === Kind.OBJECT_TYPE_EXTENSION) {
218
+ typeNames.push(def.name.value);
219
+ }
220
+ });
221
+ if (typeNames.length === 0) {
222
+ throw new Error("No object type definition found in SDL.");
223
+ }
224
+ // Assuming there's only one type definition in the SDL
225
+ const typeName = typeNames[0];
226
+ let type = schema.getType(typeName);
227
+ let effectiveSchema = schema;
228
+ if (!type || !isObjectType(type)) {
229
+ // Type doesn't exist in the schema, extend the schema
230
+ effectiveSchema = extendSchema(schema, typeAST);
231
+ type = effectiveSchema.getType(typeName);
232
+ }
233
+ if (!type || !isObjectType(type)) {
234
+ throw new Error(`Type "${typeName}" is not a valid ObjectType.`);
235
+ }
236
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
237
+ const minimalObject = getMinimalValue(type, effectiveSchema, existingValue);
238
+ return JSON.stringify(minimalObject, null, 2);
239
+ }
240
+ function removeWhitespace(str) {
241
+ return str.replace(/\s+|\\n|\\t/g, "").toLowerCase();
242
+ }
243
+ export function compareStringsWithoutWhitespace(str1, str2) {
244
+ if (str1 === null ||
245
+ str2 === null ||
246
+ str1 === undefined ||
247
+ str2 === undefined)
248
+ return false;
249
+ return removeWhitespace(str1) === removeWhitespace(str2);
250
+ }
251
+ export function renameSchemaType(sdl, oldName, newName, scope) {
252
+ const typeSuffix = scope === "global" ? "State" : "LocalState";
253
+ const oldTypeName = `${pascalCase(oldName)}${typeSuffix}`;
254
+ const newTypeName = `${pascalCase(newName)}${typeSuffix}`;
255
+ const ast = parse(sdl);
256
+ const updatedAst = visit(ast, {
257
+ ObjectTypeDefinition: (node) => {
258
+ if (node.name.value === oldTypeName) {
259
+ return {
260
+ ...node,
261
+ name: {
262
+ ...node.name,
263
+ value: newTypeName,
264
+ },
265
+ };
266
+ }
267
+ },
268
+ });
269
+ return print(updatedAst);
270
+ }
271
+ export function initializeModelSchema(params) {
272
+ const { modelName, setStateSchema } = params;
273
+ const initialSchemaDoc = makeInitialSchemaDoc(modelName, "global");
274
+ setStateSchema(initialSchemaDoc, "global");
275
+ }
276
+ export function updateModelSchemaNames(params) {
277
+ const { oldName, newName, globalStateSchema, localStateSchema, setStateSchema, } = params;
278
+ const newSchema = renameSchemaType(globalStateSchema, oldName, newName, "global");
279
+ setStateSchema(newSchema, "global");
280
+ if (localStateSchema) {
281
+ const newLocalStateSchema = renameSchemaType(localStateSchema, oldName, newName, "local");
282
+ setStateSchema(newLocalStateSchema, "local");
283
+ }
284
+ }
285
+ export function handleModelNameChange(params) {
286
+ const { oldName, newName, globalStateSchema, setStateSchema } = params;
287
+ const hasExistingSchema = !!globalStateSchema;
288
+ if (!hasExistingSchema) {
289
+ initializeModelSchema({ modelName: newName, setStateSchema });
290
+ return;
291
+ }
292
+ updateModelSchemaNames(params);
293
+ }
@@ -0,0 +1,7 @@
1
+ import { Diagnostic } from "@codemirror/lint";
2
+ import { Kind } from "graphql";
3
+ export declare function ensureDocumentContainsNodeWithNameAndType(doc: string, nodeName: string, nodeType: keyof typeof Kind): boolean;
4
+ export declare function createNodeTypeAndNameDiagnostic(doc: string, errorMessage: string): Diagnostic | undefined;
5
+ export declare function ensureValidStateSchemaName(doc: string, modelName: string, scope: string): Diagnostic[];
6
+ export declare function ensureValidOperationSchemaInputName(doc: string | undefined, operationName: string): Diagnostic[];
7
+ //# sourceMappingURL=linting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linting.d.ts","sourceRoot":"","sources":["../../../document-model-editor/utils/linting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAS,IAAI,EAAE,MAAM,SAAS,CAAC;AAEtC,wBAAgB,yCAAyC,CACvD,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,OAAO,IAAI,GAC1B,OAAO,CAUT;AAED,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,UAAU,GAAG,SAAS,CAcxB;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,gBAoBd;AAED,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,aAAa,EAAE,MAAM,gBAqBtB"}
@@ -0,0 +1,47 @@
1
+ import { isDocumentString } from "@graphql-tools/utils";
2
+ import { pascalCase, sentenceCase } from "change-case";
3
+ import { parse, Kind } from "graphql";
4
+ export function ensureDocumentContainsNodeWithNameAndType(doc, nodeName, nodeType) {
5
+ if (!doc || !isDocumentString(doc))
6
+ return true;
7
+ const parsedDoc = parse(doc);
8
+ return parsedDoc.definitions.some((def) => {
9
+ const hasMatchingType = def.kind === Kind[nodeType];
10
+ return hasMatchingType && "name" in def && def.name?.value === nodeName;
11
+ });
12
+ }
13
+ export function createNodeTypeAndNameDiagnostic(doc, errorMessage) {
14
+ if (!doc || !isDocumentString(doc))
15
+ return;
16
+ const parsedDoc = parse(doc);
17
+ const firstNode = parsedDoc.definitions[0];
18
+ const nameNode = "name" in firstNode ? firstNode.name : null;
19
+ return {
20
+ from: nameNode?.loc?.start ?? firstNode.loc?.start ?? 0,
21
+ to: nameNode?.loc?.end ?? firstNode.loc?.end ?? 0,
22
+ severity: "error",
23
+ message: errorMessage,
24
+ };
25
+ }
26
+ export function ensureValidStateSchemaName(doc, modelName, scope) {
27
+ if (!doc || !isDocumentString(doc))
28
+ return [];
29
+ const requiredTypeName = `${pascalCase(modelName)}${scope === "local" ? "Local" : ""}State`;
30
+ if (!ensureDocumentContainsNodeWithNameAndType(doc, requiredTypeName, "OBJECT_TYPE_DEFINITION")) {
31
+ return [
32
+ createNodeTypeAndNameDiagnostic(doc, `${sentenceCase(scope)} state schema must be named ${requiredTypeName}`),
33
+ ].filter((d) => d !== undefined);
34
+ }
35
+ return [];
36
+ }
37
+ export function ensureValidOperationSchemaInputName(doc, operationName) {
38
+ if (!doc || !isDocumentString(doc))
39
+ return [];
40
+ const requiredTypeName = `${pascalCase(operationName)}Input`;
41
+ if (!ensureDocumentContainsNodeWithNameAndType(doc, requiredTypeName, "INPUT_OBJECT_TYPE_DEFINITION")) {
42
+ return [
43
+ createNodeTypeAndNameDiagnostic(doc, `Operation schema must contain an input type named ${requiredTypeName}`),
44
+ ].filter((d) => d !== undefined);
45
+ }
46
+ return [];
47
+ }
@@ -0,0 +1,3 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../document-model-editor/utils/style.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAE7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
@@ -0,0 +1,5 @@
1
+ import { twMerge } from "tailwind-merge";
2
+ import { clsx } from "clsx";
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from "react";
2
+ interface DocumentEditorProps {
3
+ readonly mode: "light" | "dark";
4
+ }
5
+ export declare function DocumentEditor(props: PropsWithChildren<DocumentEditorProps>): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=documentEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentEditor.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/documentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,2CAI3E"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function DocumentEditor(props) {
3
+ const classes = ["document-editor", `${props.mode}-mode`];
4
+ return _jsx("div", { className: classes.join(" "), children: props.children });
5
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactElement } from "react";
2
+ interface EditorToolbarComponent {
3
+ }
4
+ interface EditorToolbarProps {
5
+ readonly left?: ReactElement<EditorToolbarComponent>[];
6
+ readonly center?: ReactElement<EditorToolbarComponent>[];
7
+ readonly right?: ReactElement<EditorToolbarComponent>[];
8
+ }
9
+ export declare function EditorToolbar(props: EditorToolbarProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=editorToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorToolbar.d.ts","sourceRoot":"","sources":["../../../editor-utils/components/editorToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,UAAU,sBAAsB;CAAG;AAEnC,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC;CACzD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAgBtD"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function EditorToolbar(props) {
3
+ const left = props.left || [], center = props.center || [], right = props.right || [];
4
+ return (_jsxs("div", { className: "editor-toolbar", children: [_jsx("div", { className: "editor-toolbar--column editor-toolbar--left", children: left }), _jsx("div", { className: "editor-toolbar--column editor-toolbar--center", children: center }), _jsx("div", { className: "editor-toolbar--column editor-toolbar--right", children: right })] }));
5
+ }
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from "react";
2
+ interface EditorWorksheetProps {
3
+ readonly onClick?: () => void;
4
+ }
5
+ export declare function EditorWorksheet(props: PropsWithChildren<EditorWorksheetProps>): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=editorWorksheet.d.ts.map