@makeswift/runtime 0.28.7-canary.4 → 0.28.7-canary.5

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 (132) hide show
  1. package/dist/cjs/api/graphql/documents/queries.js +6 -6
  2. package/dist/cjs/api/graphql/documents/queries.js.map +1 -1
  3. package/dist/cjs/api/graphql/generated/types.js.map +1 -1
  4. package/dist/cjs/api/graphql-api-client.js +23 -1
  5. package/dist/cjs/api/graphql-api-client.js.map +1 -1
  6. package/dist/cjs/api/{client.js → host-api-resources-client.js} +7 -7
  7. package/dist/cjs/api/host-api-resources-client.js.map +1 -0
  8. package/dist/cjs/api/rest-api-client.js +187 -0
  9. package/dist/cjs/api/rest-api-client.js.map +1 -0
  10. package/dist/cjs/api/schema/index.js +23 -0
  11. package/dist/cjs/api/schema/index.js.map +1 -0
  12. package/dist/cjs/api/schema/page-pathname-slice.js +38 -0
  13. package/dist/cjs/api/schema/page-pathname-slice.js.map +1 -0
  14. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  15. package/dist/cjs/client/component-snapshot.js +63 -0
  16. package/dist/cjs/client/component-snapshot.js.map +1 -0
  17. package/dist/cjs/client/index.js +102 -360
  18. package/dist/cjs/client/index.js.map +1 -1
  19. package/dist/cjs/client/page-snapshot.js +33 -0
  20. package/dist/cjs/client/page-snapshot.js.map +1 -0
  21. package/dist/cjs/client/schema/component-document.js +45 -0
  22. package/dist/cjs/client/schema/component-document.js.map +1 -0
  23. package/dist/cjs/client/schema/fonts.js +38 -0
  24. package/dist/cjs/client/schema/fonts.js.map +1 -0
  25. package/dist/cjs/client/schema/get-page.js +39 -0
  26. package/dist/cjs/client/schema/get-page.js.map +1 -0
  27. package/dist/cjs/client/schema/get-pages.js +68 -0
  28. package/dist/cjs/client/schema/get-pages.js.map +1 -0
  29. package/dist/cjs/client/schema/index.js +31 -0
  30. package/dist/cjs/client/schema/index.js.map +1 -0
  31. package/dist/cjs/client/schema/preview-token-payload.js +34 -0
  32. package/dist/cjs/client/schema/preview-token-payload.js.map +1 -0
  33. package/dist/cjs/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  34. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  35. package/dist/cjs/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  36. package/dist/cjs/next/testing/element-data.js +3 -3
  37. package/dist/cjs/next/testing/element-data.js.map +1 -1
  38. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  39. package/dist/cjs/runtimes/react/runtime-core.js +2 -2
  40. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  41. package/dist/esm/api/graphql/documents/queries.js +4 -4
  42. package/dist/esm/api/graphql/documents/queries.js.map +1 -1
  43. package/dist/esm/api/graphql/generated/types.js.map +1 -1
  44. package/dist/esm/api/graphql-api-client.js +29 -2
  45. package/dist/esm/api/graphql-api-client.js.map +1 -1
  46. package/dist/esm/api/{client.js → host-api-resources-client.js} +3 -3
  47. package/dist/esm/api/host-api-resources-client.js.map +1 -0
  48. package/dist/esm/api/rest-api-client.js +152 -0
  49. package/dist/esm/api/rest-api-client.js.map +1 -0
  50. package/dist/esm/api/schema/index.js +2 -0
  51. package/dist/esm/api/schema/index.js.map +1 -0
  52. package/dist/esm/api/schema/page-pathname-slice.js +14 -0
  53. package/dist/esm/api/schema/page-pathname-slice.js.map +1 -0
  54. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  55. package/dist/esm/client/component-snapshot.js +39 -0
  56. package/dist/esm/client/component-snapshot.js.map +1 -0
  57. package/dist/esm/client/index.js +67 -329
  58. package/dist/esm/client/index.js.map +1 -1
  59. package/dist/esm/client/page-snapshot.js +9 -0
  60. package/dist/esm/client/page-snapshot.js.map +1 -0
  61. package/dist/esm/client/schema/component-document.js +20 -0
  62. package/dist/esm/client/schema/component-document.js.map +1 -0
  63. package/dist/esm/client/schema/fonts.js +14 -0
  64. package/dist/esm/client/schema/fonts.js.map +1 -0
  65. package/dist/esm/client/schema/get-page.js +15 -0
  66. package/dist/esm/client/schema/get-page.js.map +1 -0
  67. package/dist/esm/client/schema/get-pages.js +42 -0
  68. package/dist/esm/client/schema/get-pages.js.map +1 -0
  69. package/dist/esm/client/schema/index.js +6 -0
  70. package/dist/esm/client/schema/index.js.map +1 -0
  71. package/dist/esm/client/schema/preview-token-payload.js +10 -0
  72. package/dist/esm/client/schema/preview-token-payload.js.map +1 -0
  73. package/dist/esm/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  74. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  75. package/dist/esm/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  76. package/dist/esm/next/testing/element-data.js +1 -1
  77. package/dist/esm/next/testing/element-data.js.map +1 -1
  78. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  79. package/dist/esm/runtimes/react/runtime-core.js +2 -2
  80. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  81. package/dist/types/api/__tests__/rest-api-client.error-handling.test.d.ts +2 -0
  82. package/dist/types/api/__tests__/rest-api-client.error-handling.test.d.ts.map +1 -0
  83. package/dist/types/api/__tests__/rest-api-client.get-resources.test.d.ts +2 -0
  84. package/dist/types/api/__tests__/rest-api-client.get-resources.test.d.ts.map +1 -0
  85. package/dist/types/api/graphql/documents/queries.d.ts +1 -1
  86. package/dist/types/api/graphql/documents/queries.d.ts.map +1 -1
  87. package/dist/types/api/graphql/generated/types.d.ts +2 -2
  88. package/dist/types/api/graphql/generated/types.d.ts.map +1 -1
  89. package/dist/types/api/graphql-api-client.d.ts +5 -0
  90. package/dist/types/api/graphql-api-client.d.ts.map +1 -1
  91. package/dist/types/api/{client.d.ts → host-api-resources-client.d.ts} +2 -2
  92. package/dist/types/api/host-api-resources-client.d.ts.map +1 -0
  93. package/dist/types/api/rest-api-client.d.ts +27 -0
  94. package/dist/types/api/rest-api-client.d.ts.map +1 -0
  95. package/dist/types/api/schema/index.d.ts +2 -0
  96. package/dist/types/api/schema/index.d.ts.map +1 -0
  97. package/dist/types/api/schema/page-pathname-slice.d.ts +21 -0
  98. package/dist/types/api/schema/page-pathname-slice.d.ts.map +1 -0
  99. package/dist/types/client/component-snapshot.d.ts +25 -0
  100. package/dist/types/client/component-snapshot.d.ts.map +1 -0
  101. package/dist/types/client/index.d.ts +19 -640
  102. package/dist/types/client/index.d.ts.map +1 -1
  103. package/dist/types/client/page-snapshot.d.ts +62 -0
  104. package/dist/types/client/page-snapshot.d.ts.map +1 -0
  105. package/dist/types/client/schema/component-document.d.ts +285 -0
  106. package/dist/types/client/schema/component-document.d.ts.map +1 -0
  107. package/dist/types/client/schema/fonts.d.ts +27 -0
  108. package/dist/types/client/schema/fonts.d.ts.map +1 -0
  109. package/dist/types/client/schema/get-page.d.ts +30 -0
  110. package/dist/types/client/schema/get-page.d.ts.map +1 -0
  111. package/dist/types/client/schema/get-pages.d.ts +202 -0
  112. package/dist/types/client/schema/get-pages.d.ts.map +1 -0
  113. package/dist/types/client/schema/index.d.ts +6 -0
  114. package/dist/types/client/schema/index.d.ts.map +1 -0
  115. package/dist/types/client/schema/preview-token-payload.d.ts +19 -0
  116. package/dist/types/client/schema/preview-token-payload.d.ts.map +1 -0
  117. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts +1 -1
  118. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
  119. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +1 -1
  120. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
  121. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts +1 -1
  122. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
  123. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts +1 -1
  124. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts.map +1 -1
  125. package/package.json +1 -1
  126. package/dist/cjs/api/client.js.map +0 -1
  127. package/dist/esm/api/client.js.map +0 -1
  128. package/dist/types/api/client.d.ts.map +0 -1
  129. package/dist/types/client/tests/client.error-handling.test.d.ts +0 -2
  130. package/dist/types/client/tests/client.error-handling.test.d.ts.map +0 -1
  131. package/dist/types/client/tests/client.get-resources.test.d.ts +0 -2
  132. package/dist/types/client/tests/client.get-resources.test.d.ts.map +0 -1
@@ -21,18 +21,18 @@ __export(queries_exports, {
21
21
  CreateTableRecordMutation: () => CreateTableRecordMutation,
22
22
  FileQuery: () => FileQuery,
23
23
  GlobalElementQuery: () => GlobalElementQuery,
24
- IntrospectedResourcesQuery: () => IntrospectedResourcesQuery,
25
24
  SwatchQuery: () => SwatchQuery,
26
25
  TableQuery: () => TableQuery,
27
26
  TypographiesQuery: () => TypographiesQuery,
28
- TypographyQuery: () => TypographyQuery
27
+ TypographyQuery: () => TypographyQuery,
28
+ UnversionedResourcesQuery: () => UnversionedResourcesQuery
29
29
  });
30
30
  module.exports = __toCommonJS(queries_exports);
31
31
  var import_fragments = require("./fragments");
32
- const IntrospectedResourcesQuery = (
32
+ const UnversionedResourcesQuery = (
33
33
  /* GraphQL */
34
34
  `
35
- query IntrospectedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {
35
+ query UnversionedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {
36
36
  files(ids: $fileIds) {
37
37
  ...File
38
38
  }
@@ -135,10 +135,10 @@ const CreateTableRecordMutation = (
135
135
  CreateTableRecordMutation,
136
136
  FileQuery,
137
137
  GlobalElementQuery,
138
- IntrospectedResourcesQuery,
139
138
  SwatchQuery,
140
139
  TableQuery,
141
140
  TypographiesQuery,
142
- TypographyQuery
141
+ TypographyQuery,
142
+ UnversionedResourcesQuery
143
143
  });
144
144
  //# sourceMappingURL=queries.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/api/graphql/documents/queries.ts"],"sourcesContent":["import {\n FileFragment,\n GlobalElementFragment,\n SwatchFragment,\n TableFragment,\n TypographyFragment,\n} from './fragments'\n\nexport const IntrospectedResourcesQuery = /* GraphQL */ `\n query IntrospectedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {\n files(ids: $fileIds) {\n ...File\n }\n\n tables(ids: $tableIds) {\n ...Table\n }\n }\n\n ${FileFragment}\n ${TableFragment}\n`\n\nexport const SwatchQuery = /* GraphQL */ `\n query Swatch($swatchId: ID!) {\n swatch(id: $swatchId) {\n ...Swatch\n }\n }\n\n ${SwatchFragment}\n`\n\nexport const FileQuery = /* GraphQL */ `\n query File($fileId: ID!) {\n file(id: $fileId) {\n ...File\n }\n }\n\n ${FileFragment}\n`\n\nexport const TypographyQuery = /* GraphQL */ `\n query Typography($typographyId: ID!) {\n typography(id: $typographyId) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const TableQuery = /* GraphQL */ `\n query Table($tableId: ID!) {\n table(id: $tableId) {\n ...Table\n }\n }\n\n ${TableFragment}\n`\n\nexport const TypographiesQuery = /* GraphQL */ `\n query Typographies($typographyIds: [ID!]!) {\n typographies(ids: $typographyIds) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const GlobalElementQuery = /* GraphQL */ `\n query GlobalElement($globalElementId: ID!) {\n globalElement(id: $globalElementId) {\n ...GlobalElement\n }\n }\n\n ${GlobalElementFragment}\n`\n\nexport const CreateTableRecordMutation = /* GraphQL */ `\n mutation CreateTableRecord($input: CreateTableRecordInput!) {\n createTableRecord(input: $input) {\n tableRecord {\n id\n }\n }\n }\n`\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMO;AAEA,MAAM;AAAA;AAAA,EAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWpD,6BAAY;AAAA,IACZ,8BAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOrC,+BAAc;AAAA;AAAA;AAGX,MAAM;AAAA;AAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnC,6BAAY;AAAA;AAAA;AAGT,MAAM;AAAA;AAAA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOzC,mCAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOpC,8BAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO3C,mCAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO5C,sCAAqB;AAAA;AAAA;AAGlB,MAAM;AAAA;AAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/api/graphql/documents/queries.ts"],"sourcesContent":["import {\n FileFragment,\n GlobalElementFragment,\n SwatchFragment,\n TableFragment,\n TypographyFragment,\n} from './fragments'\n\nexport const UnversionedResourcesQuery = /* GraphQL */ `\n query UnversionedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {\n files(ids: $fileIds) {\n ...File\n }\n\n tables(ids: $tableIds) {\n ...Table\n }\n }\n\n ${FileFragment}\n ${TableFragment}\n`\n\nexport const SwatchQuery = /* GraphQL */ `\n query Swatch($swatchId: ID!) {\n swatch(id: $swatchId) {\n ...Swatch\n }\n }\n\n ${SwatchFragment}\n`\n\nexport const FileQuery = /* GraphQL */ `\n query File($fileId: ID!) {\n file(id: $fileId) {\n ...File\n }\n }\n\n ${FileFragment}\n`\n\nexport const TypographyQuery = /* GraphQL */ `\n query Typography($typographyId: ID!) {\n typography(id: $typographyId) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const TableQuery = /* GraphQL */ `\n query Table($tableId: ID!) {\n table(id: $tableId) {\n ...Table\n }\n }\n\n ${TableFragment}\n`\n\nexport const TypographiesQuery = /* GraphQL */ `\n query Typographies($typographyIds: [ID!]!) {\n typographies(ids: $typographyIds) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const GlobalElementQuery = /* GraphQL */ `\n query GlobalElement($globalElementId: ID!) {\n globalElement(id: $globalElementId) {\n ...GlobalElement\n }\n }\n\n ${GlobalElementFragment}\n`\n\nexport const CreateTableRecordMutation = /* GraphQL */ `\n mutation CreateTableRecord($input: CreateTableRecordInput!) {\n createTableRecord(input: $input) {\n tableRecord {\n id\n }\n }\n }\n`\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMO;AAEA,MAAM;AAAA;AAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWnD,6BAAY;AAAA,IACZ,8BAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOrC,+BAAc;AAAA;AAAA;AAGX,MAAM;AAAA;AAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnC,6BAAY;AAAA;AAAA;AAGT,MAAM;AAAA;AAAA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOzC,mCAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOpC,8BAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO3C,mCAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO5C,sCAAqB;AAAA;AAAA;AAGlB,MAAM;AAAA;AAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/api/graphql/generated/types.ts"],"sourcesContent":["export type Maybe<T> = T | null\nexport type InputMaybe<T> = Maybe<T>\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\ntype Scalars = {\n ID: string\n JSON: Json\n Locale: string\n}\n\nexport type CreateTableRecordInput = {\n data: CreateTableRecordInputData\n}\n\nexport type CreateTableRecordInputData = {\n columns: Array<CreateTableRecordInputDataColumn>\n tableId?: InputMaybe<Scalars['ID']>\n}\n\nexport type CreateTableRecordInputDataColumn = {\n columnId: Scalars['ID']\n data: Scalars['JSON']\n}\n\nexport const SnippetLocation = {\n Body: 'BODY',\n Head: 'HEAD',\n} as const\n\nexport type SnippetLocation = (typeof SnippetLocation)[keyof typeof SnippetLocation]\n\nexport type SwatchFragment = {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n}\n\nexport type FileFragment = {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n}\n\nexport type TypographyFragment = {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n}\n\nexport type PagePathnameSliceFragment = {\n __typename: 'PagePathnameSlice'\n id: string\n pathname: string\n}\n\nexport type GlobalElementFragment = { __typename: 'GlobalElement'; id: string; data: Json }\n\nexport type LocalizedGlobalElementFragment = {\n __typename: 'LocalizedGlobalElement'\n id: string\n data: Json\n}\n\nexport type TableFragment = {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n}\n\nexport type SnippetFragment = {\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n}\n\nexport type PageFragment = {\n __typename: 'Page'\n id: string\n snippets: Array<{\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n }>\n}\n\nexport type SiteFragment = {\n __typename: 'Site'\n id: string\n googleFonts: {\n edges: Array<{\n activeVariants: Array<{ specifier: string }>\n node: { family: string; variants: Array<{ specifier: string }> }\n } | null>\n }\n}\n\nexport type IntrospectedResourcesQueryVariables = Exact<{\n fileIds: Array<Scalars['ID']> | Scalars['ID']\n tableIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type IntrospectedResourcesQueryResult = {\n files: Array<{\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null>\n tables: Array<{\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null>\n}\n\nexport type SwatchQueryVariables = Exact<{\n swatchId: Scalars['ID']\n}>\n\nexport type SwatchQueryResult = {\n swatch: {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n } | null\n}\n\nexport type FileQueryVariables = Exact<{\n fileId: Scalars['ID']\n}>\n\nexport type FileQueryResult = {\n file: {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null\n}\n\nexport type TypographyQueryVariables = Exact<{\n typographyId: Scalars['ID']\n}>\n\nexport type TypographyQueryResult = {\n typography: {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null\n}\n\nexport type TableQueryVariables = Exact<{\n tableId: Scalars['ID']\n}>\n\nexport type TableQueryResult = {\n table: {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null\n}\n\nexport type TypographiesQueryVariables = Exact<{\n typographyIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type TypographiesQueryResult = {\n typographies: Array<{\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null>\n}\n\nexport type GlobalElementQueryVariables = Exact<{\n globalElementId: Scalars['ID']\n}>\n\nexport type GlobalElementQueryResult = {\n globalElement: { __typename: 'GlobalElement'; id: string; data: Json } | null\n}\n\nexport type CreateTableRecordMutationVariables = Exact<{\n input: CreateTableRecordInput\n}>\n\nexport type CreateTableRecordMutationResult = { createTableRecord: { tableRecord: { id: string } } }\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM;AACR;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/api/graphql/generated/types.ts"],"sourcesContent":["export type Maybe<T> = T | null\nexport type InputMaybe<T> = Maybe<T>\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\ntype Scalars = {\n ID: string\n JSON: Json\n Locale: string\n}\n\nexport type CreateTableRecordInput = {\n data: CreateTableRecordInputData\n}\n\nexport type CreateTableRecordInputData = {\n columns: Array<CreateTableRecordInputDataColumn>\n tableId?: InputMaybe<Scalars['ID']>\n}\n\nexport type CreateTableRecordInputDataColumn = {\n columnId: Scalars['ID']\n data: Scalars['JSON']\n}\n\nexport const SnippetLocation = {\n Body: 'BODY',\n Head: 'HEAD',\n} as const\n\nexport type SnippetLocation = (typeof SnippetLocation)[keyof typeof SnippetLocation]\n\nexport type SwatchFragment = {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n}\n\nexport type FileFragment = {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n}\n\nexport type TypographyFragment = {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n}\n\nexport type PagePathnameSliceFragment = {\n __typename: 'PagePathnameSlice'\n id: string\n pathname: string\n}\n\nexport type GlobalElementFragment = { __typename: 'GlobalElement'; id: string; data: Json }\n\nexport type LocalizedGlobalElementFragment = {\n __typename: 'LocalizedGlobalElement'\n id: string\n data: Json\n}\n\nexport type TableFragment = {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n}\n\nexport type SnippetFragment = {\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n}\n\nexport type PageFragment = {\n __typename: 'Page'\n id: string\n snippets: Array<{\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n }>\n}\n\nexport type SiteFragment = {\n __typename: 'Site'\n id: string\n googleFonts: {\n edges: Array<{\n activeVariants: Array<{ specifier: string }>\n node: { family: string; variants: Array<{ specifier: string }> }\n } | null>\n }\n}\n\nexport type UnversionedResourcesQueryVariables = Exact<{\n fileIds: Array<Scalars['ID']> | Scalars['ID']\n tableIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type UnversionedResourcesQueryResult = {\n files: Array<{\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null>\n tables: Array<{\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null>\n}\n\nexport type SwatchQueryVariables = Exact<{\n swatchId: Scalars['ID']\n}>\n\nexport type SwatchQueryResult = {\n swatch: {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n } | null\n}\n\nexport type FileQueryVariables = Exact<{\n fileId: Scalars['ID']\n}>\n\nexport type FileQueryResult = {\n file: {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null\n}\n\nexport type TypographyQueryVariables = Exact<{\n typographyId: Scalars['ID']\n}>\n\nexport type TypographyQueryResult = {\n typography: {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null\n}\n\nexport type TableQueryVariables = Exact<{\n tableId: Scalars['ID']\n}>\n\nexport type TableQueryResult = {\n table: {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null\n}\n\nexport type TypographiesQueryVariables = Exact<{\n typographyIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type TypographiesQueryResult = {\n typographies: Array<{\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null>\n}\n\nexport type GlobalElementQueryVariables = Exact<{\n globalElementId: Scalars['ID']\n}>\n\nexport type GlobalElementQueryResult = {\n globalElement: { __typename: 'GlobalElement'; id: string; data: Json } | null\n}\n\nexport type CreateTableRecordMutationVariables = Exact<{\n input: CreateTableRecordInput\n}>\n\nexport type CreateTableRecordMutationResult = { createTableRecord: { tableRecord: { id: string } } }\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM;AACR;","names":[]}
@@ -26,11 +26,33 @@ var import_documents = require("./graphql/documents");
26
26
  class MakeswiftGraphQLApiClient {
27
27
  graphqlClient;
28
28
  constructor({ endpoint }) {
29
- this.graphqlClient = new import_client.GraphQLClient(endpoint);
29
+ this.graphqlClient = new import_client.GraphQLClient(endpoint, {
30
+ "makeswift-runtime-version": "0.28.7-canary.5"
31
+ });
30
32
  }
31
33
  async createTableRecord(tableId, columns) {
32
34
  await this.graphqlClient.request(import_documents.CreateTableRecordMutation, { input: { data: { tableId, columns } } });
33
35
  }
36
+ async getUnversionedResources({
37
+ fileIds,
38
+ tableIds
39
+ }) {
40
+ return await this.graphqlClient.request(import_documents.UnversionedResourcesQuery, { fileIds, tableIds });
41
+ }
42
+ async getFile(fileId) {
43
+ const result = await this.graphqlClient.request(
44
+ import_documents.FileQuery,
45
+ { fileId }
46
+ );
47
+ return result.file;
48
+ }
49
+ async getTable(tableId) {
50
+ const result = await this.graphqlClient.request(
51
+ import_documents.TableQuery,
52
+ { tableId }
53
+ );
54
+ return result.table;
55
+ }
34
56
  }
35
57
  // Annotate the CommonJS export names for ESM import in node:
36
58
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/graphql-api-client.ts"],"sourcesContent":["import { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport class MakeswiftGraphQLApiClient {\n readonly graphqlClient: GraphQLClient\n\n constructor({ endpoint }: { endpoint: string }) {\n this.graphqlClient = new GraphQLClient(endpoint)\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8B;AAC9B,uBAA0C;AAMnC,MAAM,0BAA0B;AAAA,EAC5B;AAAA,EAET,YAAY,EAAE,SAAS,GAAyB;AAC9C,SAAK,gBAAgB,IAAI,4BAAc,QAAQ;AAAA,EACjD;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/api/graphql-api-client.ts"],"sourcesContent":["import { GraphQLClient } from './graphql/client'\n\nimport {\n CreateTableRecordMutation,\n FileQuery,\n TableQuery,\n UnversionedResourcesQuery,\n} from './graphql/documents'\n\nimport {\n type CreateTableRecordMutationResult,\n type CreateTableRecordMutationVariables,\n type FileQueryResult,\n type FileQueryVariables,\n type TableQueryResult,\n type TableQueryVariables,\n type UnversionedResourcesQueryResult,\n type UnversionedResourcesQueryVariables,\n} from './graphql/generated/types'\n\nimport { type File, type Table } from './types'\n\nexport class MakeswiftGraphQLApiClient {\n readonly graphqlClient: GraphQLClient\n\n constructor({ endpoint }: { endpoint: string }) {\n this.graphqlClient = new GraphQLClient(endpoint, {\n 'makeswift-runtime-version': PACKAGE_VERSION,\n })\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n async getUnversionedResources({\n fileIds,\n tableIds,\n }: UnversionedResourcesQueryVariables): Promise<UnversionedResourcesQueryResult> {\n return await this.graphqlClient.request<\n UnversionedResourcesQueryResult,\n UnversionedResourcesQueryVariables\n >(UnversionedResourcesQuery, { fileIds, tableIds })\n }\n\n async getFile(fileId: string): Promise<File | null> {\n const result = await this.graphqlClient.request<FileQueryResult, FileQueryVariables>(\n FileQuery,\n { fileId },\n )\n\n return result.file\n }\n\n async getTable(tableId: string): Promise<Table | null> {\n const result = await this.graphqlClient.request<TableQueryResult, TableQueryVariables>(\n TableQuery,\n { tableId },\n )\n\n return result.table\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8B;AAE9B,uBAKO;AAeA,MAAM,0BAA0B;AAAA,EAC5B;AAAA,EAET,YAAY,EAAE,SAAS,GAAyB;AAC9C,SAAK,gBAAgB,IAAI,4BAAc,UAAU;AAAA,MAC/C,6BAA6B;AAAA,IAC/B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,MAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAAiF;AAC/E,WAAO,MAAM,KAAK,cAAc,QAG9B,4CAA2B,EAAE,SAAS,SAAS,CAAC;AAAA,EACpD;AAAA,EAEA,MAAM,QAAQ,QAAsC;AAClD,UAAM,SAAS,MAAM,KAAK,cAAc;AAAA,MACtC;AAAA,MACA,EAAE,OAAO;AAAA,IACX;AAEA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,SAAS,SAAwC;AACrD,UAAM,SAAS,MAAM,KAAK,cAAc;AAAA,MACtC;AAAA,MACA,EAAE,QAAQ;AAAA,IACZ;AAEA,WAAO,OAAO;AAAA,EAChB;AACF;","names":[]}
@@ -16,18 +16,18 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var client_exports = {};
20
- __export(client_exports, {
19
+ var host_api_resources_client_exports = {};
20
+ __export(host_api_resources_client_exports, {
21
21
  CacheData: () => import_api_resources_client2.CacheData,
22
- MakeswiftHostApiClient: () => MakeswiftHostApiClient
22
+ HostApiResourcesClient: () => HostApiResourcesClient
23
23
  });
24
- module.exports = __toCommonJS(client_exports);
24
+ module.exports = __toCommonJS(host_api_resources_client_exports);
25
25
  var import_fetch_api_resource = require("../state/api-client/fetch-api-resource");
26
26
  var import_client_store = require("../state/api-client/client-store");
27
27
  var import_types = require("./types");
28
28
  var import_api_resources_client = require("./api-resources-client");
29
29
  var import_api_resources_client2 = require("./api-resources-client");
30
- class MakeswiftHostApiClient extends import_api_resources_client.ApiResourcesClient {
30
+ class HostApiResourcesClient extends import_api_resources_client.ApiResourcesClient {
31
31
  fetch;
32
32
  constructor({
33
33
  fetch,
@@ -77,6 +77,6 @@ class MakeswiftHostApiClient extends import_api_resources_client.ApiResourcesCli
77
77
  // Annotate the CommonJS export names for ESM import in node:
78
78
  0 && (module.exports = {
79
79
  CacheData,
80
- MakeswiftHostApiClient
80
+ HostApiResourcesClient
81
81
  });
82
- //# sourceMappingURL=client.js.map
82
+ //# sourceMappingURL=host-api-resources-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/host-api-resources-client.ts"],"sourcesContent":["import { type State as ApiClientState } from '../state/api-client/state'\nimport { type HttpFetch, fetchAPIResource } from '../state/api-client/fetch-api-resource'\nimport { configureClientStore } from '../state/api-client/client-store'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Table,\n type Typography,\n APIResourceType,\n} from './types'\n\nimport { ApiResourcesClient } from './api-resources-client'\n\nexport { CacheData } from './api-resources-client'\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class HostApiResourcesClient extends ApiResourcesClient {\n readonly fetch: HttpFetch\n\n constructor({\n fetch,\n preloadedState,\n }: {\n fetch: HttpFetch\n preloadedState: Partial<ApiClientState>\n }) {\n super({\n store: configureClientStore({ preloadedState }),\n })\n\n this.fetch = fetch\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch))\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.File, fileId, this.fetch))\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.GlobalElement, globalElementId, this.fetch),\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.LocalizedGlobalElement, globalElementId, this.fetch, locale),\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.PagePathnameSlice, pageId, this.fetch, locale),\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.Table, tableId, this.fetch))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAAiD;AACjD,0BAAqC;AAErC,mBASO;AAEP,kCAAmC;AAEnC,IAAAA,+BAA0B;AAqBnB,MAAM,+BAA+B,+CAAmB;AAAA,EACpD;AAAA,EAET,YAAY;AAAA,IACV;AAAA,IACA;AAAA,EACF,GAGG;AACD,UAAM;AAAA,MACJ,WAAO,0CAAqB,EAAE,eAAe,CAAC;AAAA,IAChD,CAAC;AAED,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MAAM,KAAK,MAAM,aAAS,4CAAiB,6BAAgB,QAAQ,UAAU,KAAK,KAAK,CAAC;AAAA,EACjG;AAAA,EAEA,MAAM,UAAU,QAAsC;AACpD,WAAO,MAAM,KAAK,MAAM,aAAS,4CAAiB,6BAAgB,MAAM,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC7F;AAAA,EAEA,MAAM,gBAAgB,cAAkD;AACtE,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,YAAY,cAAc,KAAK,KAAK;AAAA,IACvE;AAAA,EACF;AAAA,EAEA,MAAM,mBAAmB,iBAAwD;AAC/E,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,eAAe,iBAAiB,KAAK,KAAK;AAAA,IAC7E;AAAA,EACF;AAAA,EAEA,MAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;AAAA,EACF,GAG2C;AACzC,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,wBAAwB,iBAAiB,KAAK,OAAO,MAAM;AAAA,IAC9F;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF,GAGsC;AACpC,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,mBAAmB,QAAQ,KAAK,OAAO,MAAM;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,MAAM,aAAS,4CAAiB,6BAAgB,OAAO,SAAS,KAAK,KAAK,CAAC;AAAA,EAC/F;AACF;","names":["import_api_resources_client"]}
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var rest_api_client_exports = {};
30
+ __export(rest_api_client_exports, {
31
+ MakeswiftRestAPIClient: () => MakeswiftRestAPIClient,
32
+ failedResponseBody: () => failedResponseBody
33
+ });
34
+ module.exports = __toCommonJS(rest_api_client_exports);
35
+ var Schema = __toESM(require("./schema"));
36
+ class MakeswiftRestAPIClient {
37
+ apiKey;
38
+ apiOrigin;
39
+ constructor({ apiKey, apiOrigin }) {
40
+ this.apiKey = apiKey;
41
+ this.apiOrigin = apiOrigin;
42
+ }
43
+ async getSwatch(swatchId, siteVersion) {
44
+ const response = await this.fetch(`v3/swatches/${swatchId}`, siteVersion);
45
+ if (!response.ok) {
46
+ const failedBody = await failedResponseBody(response);
47
+ if (response.status !== 404) {
48
+ console.error(`Failed to get swatch '${swatchId}'`, {
49
+ response: failedBody,
50
+ siteVersion
51
+ });
52
+ }
53
+ return null;
54
+ }
55
+ const swatch = await response.json();
56
+ return swatch;
57
+ }
58
+ async getTypography(typographyId, siteVersion) {
59
+ const response = await this.fetch(`v3/typographies/${typographyId}`, siteVersion);
60
+ if (!response.ok) {
61
+ const failedBody = await failedResponseBody(response);
62
+ if (response.status !== 404) {
63
+ console.error(`Failed to get typography '${typographyId}'`, {
64
+ response: failedBody,
65
+ siteVersion
66
+ });
67
+ }
68
+ return null;
69
+ }
70
+ const typography = await response.json();
71
+ return typography;
72
+ }
73
+ async getGlobalElement(globalElementId, siteVersion) {
74
+ const response = await this.fetch(`v3/global-elements/${globalElementId}`, siteVersion);
75
+ if (!response.ok) {
76
+ const failedBody = await failedResponseBody(response);
77
+ if (response.status !== 404) {
78
+ console.error(`Failed to get global element '${globalElementId}'`, {
79
+ response: failedBody,
80
+ siteVersion
81
+ });
82
+ }
83
+ return null;
84
+ }
85
+ const globalElement = await response.json();
86
+ return globalElement;
87
+ }
88
+ async getLocalizedGlobalElement(globalElementId, locale, siteVersion) {
89
+ const response = await this.fetch(
90
+ `v3/localized-global-elements/${globalElementId}?locale=${locale}`,
91
+ siteVersion
92
+ );
93
+ if (!response.ok) {
94
+ const failedBody = await failedResponseBody(response);
95
+ if (response.status !== 404) {
96
+ console.error(`Failed to get localized global element '${globalElementId}'`, {
97
+ response: failedBody,
98
+ siteVersion,
99
+ locale
100
+ });
101
+ }
102
+ return null;
103
+ }
104
+ const localizedGlobalElement = await response.json();
105
+ return localizedGlobalElement;
106
+ }
107
+ async getPagePathnameSlices(pageIds, siteVersion, { locale }) {
108
+ if (pageIds.length === 0)
109
+ return [];
110
+ const url = new URL(`v3/page-pathname-slices/bulk`, this.apiOrigin);
111
+ pageIds.forEach((id) => url.searchParams.append("ids", id));
112
+ if (locale != null)
113
+ url.searchParams.set("locale", locale);
114
+ const response = await this.fetch(url.pathname + url.search, siteVersion);
115
+ if (!response.ok) {
116
+ console.error(`Failed to get page pathname slice(s) for ${pageIds.join(", ")}`, {
117
+ response: await failedResponseBody(response),
118
+ siteVersion,
119
+ locale
120
+ });
121
+ return [];
122
+ }
123
+ const json = await response.json();
124
+ const pagePathnameSlices = Schema.pagePathnameSlices.parse(json);
125
+ return pagePathnameSlices.map((pagePathnameSlice) => {
126
+ if (pagePathnameSlice == null)
127
+ return null;
128
+ return {
129
+ ...pagePathnameSlice,
130
+ id: pagePathnameSlice.basePageId,
131
+ localizedPathname: pagePathnameSlice.localizedPathname ?? null
132
+ };
133
+ });
134
+ }
135
+ async getPagePathnameSlice(pageId, siteVersion, { locale } = {}) {
136
+ const pagePathnameSlices = await this.getPagePathnameSlices([pageId], siteVersion, { locale });
137
+ return pagePathnameSlices.at(0) ?? null;
138
+ }
139
+ async fetch(path, siteVersion, init) {
140
+ const requestUrl = new URL(path, this.apiOrigin);
141
+ const requestHeaders = new Headers({
142
+ "x-api-key": this.apiKey,
143
+ "makeswift-site-api-key": this.apiKey,
144
+ "makeswift-runtime-version": "0.28.7-canary.5"
145
+ });
146
+ if (siteVersion?.token) {
147
+ requestUrl.searchParams.set("version", siteVersion.version);
148
+ requestHeaders.set("makeswift-preview-token", siteVersion.token);
149
+ }
150
+ if (init?.headers) {
151
+ new Headers(init.headers).forEach((value, key) => {
152
+ requestHeaders.set(key, value);
153
+ });
154
+ }
155
+ const response = await fetch(requestUrl.toString(), {
156
+ ...init,
157
+ headers: requestHeaders,
158
+ ...siteVersion != null ? { cache: "no-store" } : {},
159
+ ...this.fetchOptions(siteVersion)
160
+ });
161
+ return response;
162
+ }
163
+ /**
164
+ * Override this method to provide additional fetch options, e.g. revalidation, cache tags, etc.
165
+ */
166
+ fetchOptions(_siteVersion) {
167
+ return {};
168
+ }
169
+ }
170
+ async function failedResponseBody(response) {
171
+ try {
172
+ const text = await response.text();
173
+ try {
174
+ return JSON.parse(text);
175
+ } catch {
176
+ return text;
177
+ }
178
+ } catch (e) {
179
+ return `Failed to extract response body: ${e}`;
180
+ }
181
+ }
182
+ // Annotate the CommonJS export names for ESM import in node:
183
+ 0 && (module.exports = {
184
+ MakeswiftRestAPIClient,
185
+ failedResponseBody
186
+ });
187
+ //# sourceMappingURL=rest-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/rest-api-client.ts"],"sourcesContent":["import {\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Typography,\n} from './types'\n\nimport { type SiteVersion } from './site-version'\nimport * as Schema from './schema'\n\nexport class MakeswiftRestAPIClient {\n readonly apiKey: string\n readonly apiOrigin: string\n\n constructor({ apiKey, apiOrigin }: { apiKey: string; apiOrigin: string }) {\n this.apiKey = apiKey\n this.apiOrigin = apiOrigin\n }\n\n async getSwatch(swatchId: string, siteVersion: SiteVersion | null): Promise<Swatch | null> {\n const response = await this.fetch(`v3/swatches/${swatchId}`, siteVersion)\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get swatch '${swatchId}'`, {\n response: failedBody,\n siteVersion,\n })\n }\n\n return null\n }\n\n const swatch = await response.json()\n\n return swatch\n }\n\n async getTypography(\n typographyId: string,\n siteVersion: SiteVersion | null,\n ): Promise<Typography | null> {\n const response = await this.fetch(`v3/typographies/${typographyId}`, siteVersion)\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get typography '${typographyId}'`, {\n response: failedBody,\n siteVersion,\n })\n }\n\n return null\n }\n\n const typography = await response.json()\n\n return typography\n }\n\n async getGlobalElement(\n globalElementId: string,\n siteVersion: SiteVersion | null,\n ): Promise<GlobalElement | null> {\n const response = await this.fetch(`v3/global-elements/${globalElementId}`, siteVersion)\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get global element '${globalElementId}'`, {\n response: failedBody,\n siteVersion,\n })\n }\n\n return null\n }\n\n const globalElement = await response.json()\n\n return globalElement\n }\n\n async getLocalizedGlobalElement(\n globalElementId: string,\n locale: string,\n siteVersion: SiteVersion | null,\n ): Promise<LocalizedGlobalElement | null> {\n const response = await this.fetch(\n `v3/localized-global-elements/${globalElementId}?locale=${locale}`,\n siteVersion,\n )\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get localized global element '${globalElementId}'`, {\n response: failedBody,\n siteVersion,\n locale,\n })\n }\n\n return null\n }\n\n const localizedGlobalElement = await response.json()\n\n return localizedGlobalElement\n }\n\n async getPagePathnameSlices(\n pageIds: string[],\n siteVersion: SiteVersion | null,\n { locale }: { locale?: string | null },\n ): Promise<(PagePathnameSlice | null)[]> {\n if (pageIds.length === 0) return []\n\n const url = new URL(`v3/page-pathname-slices/bulk`, this.apiOrigin)\n\n pageIds.forEach(id => url.searchParams.append('ids', id))\n if (locale != null) url.searchParams.set('locale', locale)\n\n const response = await this.fetch(url.pathname + url.search, siteVersion)\n\n if (!response.ok) {\n console.error(`Failed to get page pathname slice(s) for ${pageIds.join(', ')}`, {\n response: await failedResponseBody(response),\n siteVersion,\n locale,\n })\n\n return []\n }\n\n const json = await response.json()\n\n const pagePathnameSlices = Schema.pagePathnameSlices.parse(json)\n\n // We're mapping the basePageId to be the id, because we're still using the GraphQL\n // fragment as our APIResource. The id on the APIResource needs to match the pageId\n // so that we can find the corresponding page pathname slice when we call getPagePathnameSlice(pageId).\n // TODO: Update this once we move away from the GraphQL fragments.\n return pagePathnameSlices.map(pagePathnameSlice => {\n if (pagePathnameSlice == null) return null\n\n return {\n ...pagePathnameSlice,\n id: pagePathnameSlice.basePageId,\n localizedPathname: pagePathnameSlice.localizedPathname ?? null,\n }\n })\n }\n\n async getPagePathnameSlice(\n pageId: string,\n siteVersion: SiteVersion | null,\n { locale }: { locale?: string } = {},\n ): Promise<PagePathnameSlice | null> {\n const pagePathnameSlices = await this.getPagePathnameSlices([pageId], siteVersion, { locale })\n\n return pagePathnameSlices.at(0) ?? null\n }\n\n protected async fetch(\n path: string,\n siteVersion: SiteVersion | null,\n init?: RequestInit,\n ): Promise<Response> {\n const requestUrl = new URL(path, this.apiOrigin)\n\n const requestHeaders = new Headers({\n 'x-api-key': this.apiKey,\n 'makeswift-site-api-key': this.apiKey,\n 'makeswift-runtime-version': PACKAGE_VERSION,\n })\n\n if (siteVersion?.token) {\n requestUrl.searchParams.set('version', siteVersion.version)\n requestHeaders.set('makeswift-preview-token', siteVersion.token)\n }\n\n if (init?.headers) {\n new Headers(init.headers).forEach((value, key) => {\n requestHeaders.set(key, value)\n })\n }\n\n const response = await fetch(requestUrl.toString(), {\n ...init,\n headers: requestHeaders,\n ...(siteVersion != null ? { cache: 'no-store' } : {}),\n ...this.fetchOptions(siteVersion),\n })\n\n return response\n }\n\n /**\n * Override this method to provide additional fetch options, e.g. revalidation, cache tags, etc.\n */\n protected fetchOptions(_siteVersion: SiteVersion | null): Record<string, unknown> {\n return {}\n }\n}\n\n// This function attempts to consume the response body of a failed response, and\n// returns either the parsed JSON or raw text. This is useful for logging more\n// detailed error information when an API request fails.\n//\n// Cloudflare Worker Note: The Cloudflare Worker runtime has automatic deadlock\n// prevention (in the form of auto-cancelling responses) that triggers when too\n// many response bodies are unconsumed. This applies for error responses as\n// well. As such, in this client we use this function to consume the response\n// body whenever the request fails, even if we don't end up logging the body\n// itself, to avoid hitting the deadlock prevention.\nexport async function failedResponseBody(response: Response): Promise<unknown> {\n try {\n const text = await response.text()\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n } catch (e) {\n return `Failed to extract response body: ${e}`\n }\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var schema_exports = {};
17
+ module.exports = __toCommonJS(schema_exports);
18
+ __reExport(schema_exports, require("./page-pathname-slice"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./page-pathname-slice")
22
+ });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/api/schema/index.ts"],"sourcesContent":["export * from './page-pathname-slice'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,kCAAd;","names":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var page_pathname_slice_exports = {};
20
+ __export(page_pathname_slice_exports, {
21
+ pagePathnameSlices: () => pagePathnameSlices
22
+ });
23
+ module.exports = __toCommonJS(page_pathname_slice_exports);
24
+ var import_zod = require("zod");
25
+ const pagePathnameSlices = import_zod.z.array(
26
+ import_zod.z.object({
27
+ id: import_zod.z.string(),
28
+ basePageId: import_zod.z.string(),
29
+ pathname: import_zod.z.string(),
30
+ localizedPathname: import_zod.z.string().optional(),
31
+ __typename: import_zod.z.literal("PagePathnameSlice")
32
+ }).nullable()
33
+ );
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ pagePathnameSlices
37
+ });
38
+ //# sourceMappingURL=page-pathname-slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/api/schema/page-pathname-slice.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const pagePathnameSlices = z.array(\n z\n .object({\n id: z.string(),\n basePageId: z.string(),\n pathname: z.string(),\n localizedPathname: z.string().optional(),\n __typename: z.literal('PagePathnameSlice'),\n })\n .nullable(),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAEX,MAAM,qBAAqB,aAAE;AAAA,EAClC,aACG,OAAO;AAAA,IACN,IAAI,aAAE,OAAO;AAAA,IACb,YAAY,aAAE,OAAO;AAAA,IACrB,UAAU,aAAE,OAAO;AAAA,IACnB,mBAAmB,aAAE,OAAO,EAAE,SAAS;AAAA,IACvC,YAAY,aAAE,QAAQ,mBAAmB;AAAA,EAC3C,CAAC,EACA,SAAS;AACd;","names":[]}
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
28
28
  return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
29
29
  }
30
30
  return import_request_response.ApiResponse.json({
31
- version: "0.28.7-canary.4",
31
+ version: "0.28.7-canary.5",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var component_snapshot_exports = {};
20
+ __export(component_snapshot_exports, {
21
+ componentDocumentToRootEmbeddedDocument: () => componentDocumentToRootEmbeddedDocument
22
+ });
23
+ module.exports = __toCommonJS(component_snapshot_exports);
24
+ var import_read_only_documents = require("../state/modules/read-only-documents");
25
+ var import_deterministic_uuid = require("../utils/deterministic-uuid");
26
+ function componentDocumentToRootEmbeddedDocument({
27
+ document,
28
+ documentKey,
29
+ name,
30
+ type,
31
+ description,
32
+ meta
33
+ }) {
34
+ const { data: rootElement, locale, id } = document;
35
+ if (rootElement != null && rootElement.type !== type) {
36
+ throw new Error(
37
+ `Type "${rootElement.type}" does not match the expected type "${type}" from the snapshot`
38
+ );
39
+ }
40
+ const rootDocument = {
41
+ key: documentKey,
42
+ rootElement: rootElement ?? {
43
+ // Fallback rootElement
44
+ // Create a stable uuid so two different clients will have the same empty element data.
45
+ // This is needed to make presence feature work for an element that is not yet created.
46
+ key: (0, import_deterministic_uuid.deterministicUUID)({ id, locale, seed: documentKey }),
47
+ type,
48
+ props: {}
49
+ },
50
+ locale,
51
+ id,
52
+ type,
53
+ name,
54
+ meta: { ...meta, description },
55
+ __type: import_read_only_documents.EMBEDDED_DOCUMENT_TYPE
56
+ };
57
+ return rootDocument;
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ componentDocumentToRootEmbeddedDocument
62
+ });
63
+ //# sourceMappingURL=component-snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/component-snapshot.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { type CacheData } from '../api/api-resources-client'\n\nimport { EMBEDDED_DOCUMENT_TYPE, type EmbeddedDocument } from '../state/modules/read-only-documents'\n\nimport { deterministicUUID } from '../utils/deterministic-uuid'\n\nimport * as Schema from './schema/component-document'\n\nexport type MakeswiftComponentDocument = z.infer<typeof Schema.componentDocument>\nexport type MakeswiftComponentDocumentFallback = z.infer<typeof Schema.componentDocumentFallback>\n\nexport type MakeswiftComponentMetadata = {\n allowLocaleFallback: boolean\n requestedLocale: string | null\n}\n\nexport function componentDocumentToRootEmbeddedDocument({\n document,\n documentKey,\n name,\n type,\n description,\n meta,\n}: {\n document: MakeswiftComponentDocument | MakeswiftComponentDocumentFallback\n documentKey: string\n name: string\n type: string\n description?: string\n meta: MakeswiftComponentMetadata\n}): EmbeddedDocument {\n const { data: rootElement, locale, id } = document\n\n if (rootElement != null && rootElement.type !== type) {\n throw new Error(\n `Type \"${rootElement.type}\" does not match the expected type \"${type}\" from the snapshot`,\n )\n }\n\n const rootDocument: EmbeddedDocument = {\n key: documentKey,\n rootElement: rootElement ?? {\n // Fallback rootElement\n // Create a stable uuid so two different clients will have the same empty element data.\n // This is needed to make presence feature work for an element that is not yet created.\n key: deterministicUUID({ id, locale, seed: documentKey }),\n type,\n props: {},\n },\n locale,\n id,\n type,\n name,\n meta: { ...meta, description },\n __type: EMBEDDED_DOCUMENT_TYPE,\n }\n\n return rootDocument\n}\n\nexport type MakeswiftComponentSnapshot = {\n document: MakeswiftComponentDocument | MakeswiftComponentDocumentFallback\n key: string\n cacheData: CacheData\n meta: MakeswiftComponentMetadata\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iCAA8D;AAE9D,gCAAkC;AAY3B,SAAS,wCAAwC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOqB;AACnB,QAAM,EAAE,MAAM,aAAa,QAAQ,GAAG,IAAI;AAE1C,MAAI,eAAe,QAAQ,YAAY,SAAS,MAAM;AACpD,UAAM,IAAI;AAAA,MACR,SAAS,YAAY,IAAI,uCAAuC,IAAI;AAAA,IACtE;AAAA,EACF;AAEA,QAAM,eAAiC;AAAA,IACrC,KAAK;AAAA,IACL,aAAa,eAAe;AAAA;AAAA;AAAA;AAAA,MAI1B,SAAK,6CAAkB,EAAE,IAAI,QAAQ,MAAM,YAAY,CAAC;AAAA,MACxD;AAAA,MACA,OAAO,CAAC;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,EAAE,GAAG,MAAM,YAAY;AAAA,IAC7B,QAAQ;AAAA,EACV;AAEA,SAAO;AACT;","names":[]}