@cmssy/core 19.1.1 → 19.3.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.
package/dist/internal.cjs CHANGED
@@ -2,8 +2,159 @@
2
2
 
3
3
  var types = require('@cmssy/types');
4
4
 
5
+ // src/data/document.ts
6
+ function typedOperation(text) {
7
+ return text;
8
+ }
9
+ function isNode(value) {
10
+ return typeof value === "object" && value !== null && typeof value.kind === "string";
11
+ }
12
+ function name(node) {
13
+ return isNode(node) ? String(node.value ?? "") : "";
14
+ }
15
+ function printValue(node) {
16
+ if (!isNode(node)) return "null";
17
+ const value = node.value;
18
+ switch (node.kind) {
19
+ case "Variable":
20
+ return `$${name(node.name)}`;
21
+ case "IntValue":
22
+ case "FloatValue":
23
+ case "BooleanValue":
24
+ return String(value);
25
+ case "StringValue":
26
+ return node.block ? `"""
27
+ ${String(value)}
28
+ """` : JSON.stringify(String(value));
29
+ case "EnumValue":
30
+ return String(value);
31
+ case "NullValue":
32
+ return "null";
33
+ case "ListValue":
34
+ return `[${(node.values ?? []).map(printValue).join(", ")}]`;
35
+ case "ObjectValue":
36
+ return `{${(node.fields ?? []).map(
37
+ (field) => `${name(field.name)}: ${printValue(
38
+ field.value
39
+ )}`
40
+ ).join(", ")}}`;
41
+ default:
42
+ return "null";
43
+ }
44
+ }
45
+ function printType(node) {
46
+ if (!isNode(node)) return "";
47
+ switch (node.kind) {
48
+ case "NonNullType":
49
+ return `${printType(node.type)}!`;
50
+ case "ListType":
51
+ return `[${printType(node.type)}]`;
52
+ default:
53
+ return name(node.name);
54
+ }
55
+ }
56
+ function printArguments(node) {
57
+ const args = node.arguments ?? [];
58
+ if (args.length === 0) return "";
59
+ return `(${args.map(
60
+ (arg) => `${name(arg.name)}: ${printValue(
61
+ arg.value
62
+ )}`
63
+ ).join(", ")})`;
64
+ }
65
+ function printDirectives(node) {
66
+ const directives = node.directives ?? [];
67
+ if (directives.length === 0) return "";
68
+ return ` ${directives.map(
69
+ (directive) => `@${name(directive.name)}${printArguments(directive)}`
70
+ ).join(" ")}`;
71
+ }
72
+ function printSelectionSet(node, depth) {
73
+ if (!isNode(node)) return "";
74
+ const selections = node.selections ?? [];
75
+ if (selections.length === 0) return "";
76
+ const pad = " ".repeat(depth + 1);
77
+ const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
78
+ return ` {
79
+ ${body}
80
+ ${" ".repeat(depth)}}`;
81
+ }
82
+ function printSelection(node, depth) {
83
+ if (node.kind === "FragmentSpread") {
84
+ return `...${name(node.name)}${printDirectives(node)}`;
85
+ }
86
+ if (node.kind === "InlineFragment") {
87
+ const condition = node.typeCondition;
88
+ const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
89
+ return `...${on}${printDirectives(node)}${printSelectionSet(
90
+ node.selectionSet,
91
+ depth
92
+ )}`;
93
+ }
94
+ const alias = node.alias;
95
+ const prefix = isNode(alias) ? `${name(alias)}: ` : "";
96
+ return `${prefix}${name(node.name)}${printArguments(
97
+ node
98
+ )}${printDirectives(node)}${printSelectionSet(
99
+ node.selectionSet,
100
+ depth
101
+ )}`;
102
+ }
103
+ function printVariableDefinitions(node) {
104
+ const definitions = node.variableDefinitions ?? [];
105
+ if (definitions.length === 0) return "";
106
+ return `(${definitions.map((definition) => {
107
+ const variable = definition.variable;
108
+ const declared = `$${name(
109
+ isNode(variable) ? variable.name : void 0
110
+ )}: ${printType(definition.type)}`;
111
+ const defaultValue = definition.defaultValue;
112
+ return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
113
+ }).join(", ")})`;
114
+ }
115
+ function printDefinition(node) {
116
+ if (node.kind === "FragmentDefinition") {
117
+ const condition = node.typeCondition;
118
+ const on = isNode(condition) ? name(condition.name) : "";
119
+ return `fragment ${name(node.name)} on ${on}${printDirectives(
120
+ node
121
+ )}${printSelectionSet(node.selectionSet, 0)}`;
122
+ }
123
+ const operation = String(
124
+ node.operation ?? "query"
125
+ );
126
+ const operationName = name(node.name);
127
+ const head = operationName ? `${operation} ${operationName}` : operation;
128
+ return `${head}${printVariableDefinitions(node)}${printDirectives(
129
+ node
130
+ )}${printSelectionSet(node.selectionSet, 0)}`;
131
+ }
132
+ function printDocumentNode(node) {
133
+ const definitions = node.definitions ?? [];
134
+ return definitions.map(printDefinition).join("\n\n");
135
+ }
136
+ function documentText(document2) {
137
+ if (typeof document2 === "string") return document2;
138
+ if (!document2 || typeof document2 !== "object") {
139
+ throw new TypeError(
140
+ "cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
141
+ );
142
+ }
143
+ const loc = document2.loc;
144
+ if (typeof loc?.source?.body === "string") return loc.source.body;
145
+ if (document2.kind === "Document") {
146
+ const printed = printDocumentNode(document2);
147
+ if (printed.trim()) return printed;
148
+ }
149
+ const asString = String(document2);
150
+ if (asString && asString !== "[object Object]") return asString;
151
+ throw new TypeError(
152
+ "cmssy: could not read the query text off the given document"
153
+ );
154
+ }
155
+
5
156
  // src/version.ts
6
- var CMSSY_CORE_VERSION = "19.1.1" ;
157
+ var CMSSY_CORE_VERSION = "19.3.0" ;
7
158
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
8
159
 
9
160
  // src/data/http.ts
@@ -146,7 +297,7 @@ async function postGraphql(url, query, variables, options) {
146
297
  "user-agent": CMSSY_USER_AGENT,
147
298
  ...options.headers
148
299
  },
149
- body: JSON.stringify({ query, variables }),
300
+ body: JSON.stringify({ query: documentText(query), variables }),
150
301
  signal: options.signal
151
302
  },
152
303
  options.retry,
@@ -198,7 +349,7 @@ function resolvePublicUrl(config) {
198
349
  const base = resolveApiUrl(config.apiUrl).replace(/\/graphql\/?$/, "");
199
350
  return `${base}/public/${config.org}/${config.workspaceSlug}/graphql`;
200
351
  }
201
- var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
352
+ var PUBLIC_PAGE_QUERY = typedOperation(`query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
202
353
  public {
203
354
  page {
204
355
  get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
@@ -210,8 +361,8 @@ var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String
210
361
  }
211
362
  }
212
363
  }
213
- }`;
214
- var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
364
+ }`);
365
+ var PUBLIC_PAGE_DEV_QUERY = typedOperation(`query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
215
366
  public {
216
367
  page {
217
368
  get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
@@ -223,8 +374,8 @@ var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: St
223
374
  }
224
375
  }
225
376
  }
226
- }`;
227
- var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
377
+ }`);
378
+ var PUBLIC_PAGE_BY_ID_QUERY = typedOperation(`query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
228
379
  public {
229
380
  page {
230
381
  getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
@@ -235,8 +386,8 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
235
386
  }
236
387
  }
237
388
  }
238
- }`;
239
- var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
389
+ }`);
390
+ var PUBLIC_PAGES_QUERY = typedOperation(`query PublicPages($workspaceSlug: String!) {
240
391
  public {
241
392
  page {
242
393
  list(workspaceSlug: $workspaceSlug) {
@@ -247,8 +398,8 @@ var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
247
398
  }
248
399
  }
249
400
  }
250
- }`;
251
- var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
401
+ }`);
402
+ var PUBLIC_PAGE_META_QUERY = typedOperation(`query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
252
403
  public {
253
404
  page {
254
405
  get(workspaceSlug: $workspaceSlug, slug: $slug) {
@@ -260,8 +411,8 @@ var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slu
260
411
  }
261
412
  }
262
413
  }
263
- }`;
264
- var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
414
+ }`);
415
+ var PUBLIC_PAGE_LAYOUTS_QUERY = typedOperation(`query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
265
416
  public {
266
417
  page {
267
418
  layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
@@ -271,7 +422,7 @@ var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!
271
422
  }
272
423
  }
273
424
  }
274
- }`;
425
+ }`);
275
426
  function normalizeSlug(path) {
276
427
  if (Array.isArray(path)) {
277
428
  const joined = path.filter(Boolean).join("/");
@@ -293,22 +444,29 @@ async function fetchPage(config, path, options = {}) {
293
444
  headers["x-workspace-id"] = options.workspaceId;
294
445
  }
295
446
  }
296
- const data = await postGraphql(
297
- resolvePublicUrl(config),
298
- devPreview ? PUBLIC_PAGE_DEV_QUERY : PUBLIC_PAGE_QUERY,
447
+ const requestOptions = {
448
+ fetch: options.fetch,
449
+ signal: options.signal,
450
+ headers,
451
+ retry: options.retry ?? "build",
452
+ label: "page fetch"
453
+ };
454
+ const url = resolvePublicUrl(config);
455
+ const data = devPreview ? await postGraphql(
456
+ url,
457
+ PUBLIC_PAGE_DEV_QUERY,
299
458
  {
300
459
  workspaceSlug: config.workspaceSlug,
301
460
  slug,
302
461
  previewSecret,
303
- ...devPreview ? { devPreview: true } : {}
462
+ devPreview: true
304
463
  },
305
- {
306
- fetch: options.fetch,
307
- signal: options.signal,
308
- headers,
309
- retry: options.retry ?? "build",
310
- label: "page fetch"
311
- }
464
+ requestOptions
465
+ ) : await postGraphql(
466
+ url,
467
+ PUBLIC_PAGE_QUERY,
468
+ { workspaceSlug: config.workspaceSlug, slug, previewSecret },
469
+ requestOptions
312
470
  );
313
471
  const page = data?.public?.page?.get;
314
472
  if (!page) return null;
@@ -409,8 +567,9 @@ function getBlockContentForLanguage(content, locale, defaultLocale = "en", avail
409
567
  if (!(isLocale(key) && isPlainObject(value))) nonTranslatable[key] = value;
410
568
  }
411
569
  const fallbackKey = Object.keys(localeMap)[0];
412
- const chosen = localeMap[locale] ?? localeMap[defaultLocale] ?? localeMap[fallbackKey];
413
- return { ...nonTranslatable, ...chosen };
570
+ const base = localeMap[defaultLocale] ?? localeMap[fallbackKey];
571
+ const active = localeMap[locale] ?? base;
572
+ return { ...nonTranslatable, ...base, ...active };
414
573
  }
415
574
  function asBucket(value) {
416
575
  return isPlainObject(value) ? value : {};
@@ -427,7 +586,7 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
427
586
  label
428
587
  });
429
588
  }
430
- var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
589
+ var SITE_CONFIG_QUERY = typedOperation(`query PublicSiteConfig($workspaceSlug: String!) {
431
590
  public {
432
591
  siteConfig(workspaceSlug: $workspaceSlug) {
433
592
  id
@@ -443,8 +602,8 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
443
602
  }
444
603
  }
445
604
  }
446
- }`;
447
- var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String!) {
605
+ }`);
606
+ var MODEL_DEFINITIONS_QUERY = typedOperation(`query PublicModelDefinitions($workspaceId: String!) {
448
607
  public {
449
608
  model {
450
609
  definitions(workspaceId: $workspaceId) {
@@ -452,8 +611,8 @@ var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String
452
611
  }
453
612
  }
454
613
  }
455
- }`;
456
- var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {
614
+ }`);
615
+ var MODEL_RECORDS_QUERY = typedOperation(`query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {
457
616
  public {
458
617
  model {
459
618
  records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, locale: $locale, limit: $limit, offset: $offset, populate: $populate) {
@@ -463,8 +622,9 @@ var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $mode
463
622
  }
464
623
  }
465
624
  }
466
- }`;
467
- var FORM_QUERY = `query PublicForm($formId: ID!) {
625
+ }`);
626
+ var FORM_QUERY = typedOperation(
627
+ `query PublicForm($formId: ID!) {
468
628
  public {
469
629
  form {
470
630
  get(formId: $formId) {
@@ -485,8 +645,9 @@ var FORM_QUERY = `query PublicForm($formId: ID!) {
485
645
  }
486
646
  }
487
647
  }
488
- }`;
489
- var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
648
+ }`
649
+ );
650
+ var SUBMIT_FORM_MUTATION = typedOperation(`mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
490
651
  public {
491
652
  form {
492
653
  submit(formId: $formId, input: $input) {
@@ -494,7 +655,7 @@ var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitForm
494
655
  }
495
656
  }
496
657
  }
497
- }`;
658
+ }`);
498
659
 
499
660
  // src/data/settings-client.ts
500
661
  async function fetchSiteConfig(config, options = {}) {
@@ -540,154 +701,6 @@ function clearWorkspaceIdCache() {
540
701
  workspaceIdCache.clear();
541
702
  }
542
703
 
543
- // src/data/document.ts
544
- function isNode(value) {
545
- return typeof value === "object" && value !== null && typeof value.kind === "string";
546
- }
547
- function name(node) {
548
- return isNode(node) ? String(node.value ?? "") : "";
549
- }
550
- function printValue(node) {
551
- if (!isNode(node)) return "null";
552
- const value = node.value;
553
- switch (node.kind) {
554
- case "Variable":
555
- return `$${name(node.name)}`;
556
- case "IntValue":
557
- case "FloatValue":
558
- case "BooleanValue":
559
- return String(value);
560
- case "StringValue":
561
- return node.block ? `"""
562
- ${String(value)}
563
- """` : JSON.stringify(String(value));
564
- case "EnumValue":
565
- return String(value);
566
- case "NullValue":
567
- return "null";
568
- case "ListValue":
569
- return `[${(node.values ?? []).map(printValue).join(", ")}]`;
570
- case "ObjectValue":
571
- return `{${(node.fields ?? []).map(
572
- (field) => `${name(field.name)}: ${printValue(
573
- field.value
574
- )}`
575
- ).join(", ")}}`;
576
- default:
577
- return "null";
578
- }
579
- }
580
- function printType(node) {
581
- if (!isNode(node)) return "";
582
- switch (node.kind) {
583
- case "NonNullType":
584
- return `${printType(node.type)}!`;
585
- case "ListType":
586
- return `[${printType(node.type)}]`;
587
- default:
588
- return name(node.name);
589
- }
590
- }
591
- function printArguments(node) {
592
- const args = node.arguments ?? [];
593
- if (args.length === 0) return "";
594
- return `(${args.map(
595
- (arg) => `${name(arg.name)}: ${printValue(
596
- arg.value
597
- )}`
598
- ).join(", ")})`;
599
- }
600
- function printDirectives(node) {
601
- const directives = node.directives ?? [];
602
- if (directives.length === 0) return "";
603
- return ` ${directives.map(
604
- (directive) => `@${name(directive.name)}${printArguments(directive)}`
605
- ).join(" ")}`;
606
- }
607
- function printSelectionSet(node, depth) {
608
- if (!isNode(node)) return "";
609
- const selections = node.selections ?? [];
610
- if (selections.length === 0) return "";
611
- const pad = " ".repeat(depth + 1);
612
- const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
613
- return ` {
614
- ${body}
615
- ${" ".repeat(depth)}}`;
616
- }
617
- function printSelection(node, depth) {
618
- if (node.kind === "FragmentSpread") {
619
- return `...${name(node.name)}${printDirectives(node)}`;
620
- }
621
- if (node.kind === "InlineFragment") {
622
- const condition = node.typeCondition;
623
- const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
624
- return `...${on}${printDirectives(node)}${printSelectionSet(
625
- node.selectionSet,
626
- depth
627
- )}`;
628
- }
629
- const alias = node.alias;
630
- const prefix = isNode(alias) ? `${name(alias)}: ` : "";
631
- return `${prefix}${name(node.name)}${printArguments(
632
- node
633
- )}${printDirectives(node)}${printSelectionSet(
634
- node.selectionSet,
635
- depth
636
- )}`;
637
- }
638
- function printVariableDefinitions(node) {
639
- const definitions = node.variableDefinitions ?? [];
640
- if (definitions.length === 0) return "";
641
- return `(${definitions.map((definition) => {
642
- const variable = definition.variable;
643
- const declared = `$${name(
644
- isNode(variable) ? variable.name : void 0
645
- )}: ${printType(definition.type)}`;
646
- const defaultValue = definition.defaultValue;
647
- return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
648
- }).join(", ")})`;
649
- }
650
- function printDefinition(node) {
651
- if (node.kind === "FragmentDefinition") {
652
- const condition = node.typeCondition;
653
- const on = isNode(condition) ? name(condition.name) : "";
654
- return `fragment ${name(node.name)} on ${on}${printDirectives(
655
- node
656
- )}${printSelectionSet(node.selectionSet, 0)}`;
657
- }
658
- const operation = String(
659
- node.operation ?? "query"
660
- );
661
- const operationName = name(node.name);
662
- const head = operationName ? `${operation} ${operationName}` : operation;
663
- return `${head}${printVariableDefinitions(node)}${printDirectives(
664
- node
665
- )}${printSelectionSet(node.selectionSet, 0)}`;
666
- }
667
- function printDocumentNode(node) {
668
- const definitions = node.definitions ?? [];
669
- return definitions.map(printDefinition).join("\n\n");
670
- }
671
- function documentText(document2) {
672
- if (typeof document2 === "string") return document2;
673
- if (!document2 || typeof document2 !== "object") {
674
- throw new TypeError(
675
- "cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
676
- );
677
- }
678
- const loc = document2.loc;
679
- if (typeof loc?.source?.body === "string") return loc.source.body;
680
- if (document2.kind === "Document") {
681
- const printed = printDocumentNode(document2);
682
- if (printed.trim()) return printed;
683
- }
684
- const asString = String(document2);
685
- if (asString && asString !== "[object Object]") return asString;
686
- throw new TypeError(
687
- "cmssy: could not read the query text off the given document"
688
- );
689
- }
690
-
691
704
  // src/data/client.ts
692
705
  function createCmssyClient(input) {
693
706
  const config = {
@@ -741,7 +754,7 @@ function createCmssyClient(input) {
741
754
  }
742
755
 
743
756
  // src/data/block-content.ts
744
- var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
757
+ var RECORDS_BY_IDS_QUERY = typedOperation(`query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
745
758
  public {
746
759
  model {
747
760
  recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {
@@ -749,7 +762,7 @@ var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids
749
762
  }
750
763
  }
751
764
  }
752
- }`;
765
+ }`);
753
766
  var BY_IDS_CHUNK = 50;
754
767
  var COLLECTION_DEFAULT_LIMIT = 50;
755
768
  function relationModel(field) {
@@ -1016,7 +1029,11 @@ async function resolveForms(config, blocks, schemas, locale, defaultLocale, opti
1016
1029
  const entries = await Promise.all(
1017
1030
  ids.map(async (id) => {
1018
1031
  try {
1019
- const data = await client.queryScoped(FORM_QUERY, { formId: id }, options);
1032
+ const data = await client.queryScoped(
1033
+ FORM_QUERY,
1034
+ { formId: id },
1035
+ options
1036
+ );
1020
1037
  return [id, data.public.form.get];
1021
1038
  } catch (err) {
1022
1039
  if (typeof console !== "undefined") {
@@ -1,17 +1,73 @@
1
1
  export { g as fetchLayouts, h as fetchPage, j as fetchPageById, k as fetchPageMeta, l as fetchPages, r as resolveApiUrl } from './content-client-DhcHP8ln.cjs';
2
- import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, FieldDefinition, RawBlock, CmssyLayoutGroup } from '@cmssy/types';
2
+ import { CmssyFormDefinition, CmssyModelDefinition, CmssyRecordList, CmssySiteConfig, CmssyFormSubmitResponse, SubmitFormInput, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, FieldDefinition, RawBlock, CmssyLayoutGroup } from '@cmssy/types';
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
- import { G as GraphqlRequestOptions } from './locale-CsDPiYGF.cjs';
5
- export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-CsDPiYGF.cjs';
6
- import { Q as QueryScopedOptions } from './csp-Dtp9S9TS.cjs';
7
- export { F as cmssyCspHeaders, G as isDevelopment, H as layoutRegionIds, J as resolveInitialTarget, K as toCspOrigin } from './csp-Dtp9S9TS.cjs';
4
+ import { a as CmssyOperation, G as GraphqlRequestOptions } from './locale-DLGQgiu5.cjs';
5
+ export { C as CMSSY_LOCALE_HEADER, d as localeForPath, e as localeForPathname, l as localizeHref, f as resolveSiteLocales, s as splitCmssyLocale, h as splitLocaleFromPath } from './locale-DLGQgiu5.cjs';
6
+ import { Q as QueryScopedOptions } from './csp-GwcubV3k.cjs';
7
+ export { G as cmssyCspHeaders, H as isDevelopment, J as layoutRegionIds, K as resolveInitialTarget, L as toCspOrigin } from './csp-GwcubV3k.cjs';
8
8
  export { localizedPath } from './internal/locale.cjs';
9
9
 
10
- declare const SITE_CONFIG_QUERY: string;
11
- declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
12
- declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, locale: $locale, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
13
- declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin\n }\n }\n }\n }\n}";
14
- declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl\n }\n }\n }\n}";
10
+ interface SiteConfigVariables {
11
+ workspaceSlug: string;
12
+ }
13
+ interface SiteConfigResult {
14
+ public: {
15
+ siteConfig: CmssySiteConfig | null;
16
+ };
17
+ }
18
+ declare const SITE_CONFIG_QUERY: CmssyOperation<SiteConfigResult, SiteConfigVariables>;
19
+ interface ModelDefinitionsVariables {
20
+ workspaceId: string;
21
+ }
22
+ interface ModelDefinitionsResult {
23
+ public: {
24
+ model: {
25
+ definitions: CmssyModelDefinition[];
26
+ };
27
+ };
28
+ }
29
+ declare const MODEL_DEFINITIONS_QUERY: CmssyOperation<ModelDefinitionsResult, ModelDefinitionsVariables>;
30
+ interface ModelRecordsVariables {
31
+ workspaceId: string;
32
+ modelSlug: string;
33
+ filter?: Record<string, unknown> | null;
34
+ sort?: string | null;
35
+ locale?: string | null;
36
+ limit?: number | null;
37
+ offset?: number | null;
38
+ populate?: string[] | null;
39
+ }
40
+ interface ModelRecordsResult {
41
+ public: {
42
+ model: {
43
+ records: CmssyRecordList;
44
+ };
45
+ };
46
+ }
47
+ declare const MODEL_RECORDS_QUERY: CmssyOperation<ModelRecordsResult, ModelRecordsVariables>;
48
+ interface FormVariables {
49
+ formId: string;
50
+ }
51
+ interface FormResult {
52
+ public: {
53
+ form: {
54
+ get: CmssyFormDefinition | null;
55
+ };
56
+ };
57
+ }
58
+ declare const FORM_QUERY: CmssyOperation<FormResult, FormVariables>;
59
+ interface SubmitFormVariables {
60
+ formId: string;
61
+ input: SubmitFormInput;
62
+ }
63
+ interface SubmitFormResult {
64
+ public: {
65
+ form: {
66
+ submit: CmssyFormSubmitResponse;
67
+ };
68
+ };
69
+ }
70
+ declare const SUBMIT_FORM_MUTATION: CmssyOperation<SubmitFormResult, SubmitFormVariables>;
15
71
 
16
72
  declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
17
73