@slicemachine/manager 0.24.11-alpha.lg-screenshot-button-fix.1 → 0.24.11-alpha.xru-add-slice-to-slicezone-bottom.1
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/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_virtual/index2.cjs +4 -3
- package/dist/_virtual/index2.cjs.map +1 -1
- package/dist/_virtual/index2.js +4 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.cjs +3 -4
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +2 -4
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.cjs +2 -1
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.d.ts +3 -0
- package/dist/managers/customTypes/CustomTypesManager.js +2 -1
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/dist/managers/telemetry/types.cjs +4 -2
- package/dist/managers/telemetry/types.cjs.map +1 -1
- package/dist/managers/telemetry/types.d.ts +11 -1
- package/dist/managers/telemetry/types.js +4 -2
- package/dist/managers/telemetry/types.js.map +1 -1
- package/package.json +2 -2
- package/src/managers/customTypes/CustomTypesManager.ts +1 -0
- package/src/managers/telemetry/types.ts +16 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
const _commonjsHelpers = require("../../../../../../_virtual/_commonjsHelpers.cjs");
|
3
3
|
const client = require("../../../../../../_virtual/client2.cjs");
|
4
|
-
const index = require("../../../../../../_virtual/
|
4
|
+
const index = require("../../../../../../_virtual/index2.cjs");
|
5
5
|
const experimentCore_esm = require("../../../../../../_virtual/experiment-core.esm.cjs");
|
6
6
|
require("../assignment/assignment.cjs");
|
7
7
|
require("../assignment/assignment-filter.cjs");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { commonjsGlobal } from "../../../../../../_virtual/_commonjsHelpers.js";
|
2
2
|
import { __exports as client } from "../../../../../../_virtual/client2.js";
|
3
|
-
import require$$0 from "../../../../../../_virtual/
|
3
|
+
import require$$0 from "../../../../../../_virtual/index2.js";
|
4
4
|
import require$$1 from "../../../../../../_virtual/experiment-core.esm.js";
|
5
5
|
import "../assignment/assignment.js";
|
6
6
|
import "../assignment/assignment-filter.js";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
const _commonjsHelpers = require("../../_virtual/_commonjsHelpers.cjs");
|
3
|
-
const index = require("../../_virtual/
|
3
|
+
const index = require("../../_virtual/index3.cjs");
|
4
4
|
const require$$0 = require("child_process");
|
5
5
|
const parse$1 = require("./lib/parse.cjs");
|
6
6
|
const enoent$1 = require("./lib/enoent.cjs");
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { getDefaultExportFromCjs } from "../../_virtual/_commonjsHelpers.js";
|
2
|
-
import { __module as crossSpawn$1 } from "../../_virtual/
|
2
|
+
import { __module as crossSpawn$1 } from "../../_virtual/index3.js";
|
3
3
|
import require$$0 from "child_process";
|
4
4
|
import { p as parse_1 } from "./lib/parse.js";
|
5
5
|
import { e as enoent$1 } from "./lib/enoent.js";
|
package/dist/_virtual/index2.cjs
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
const _commonjsHelpers = require("./_commonjsHelpers.cjs");
|
3
|
+
const index = require('./../_node_modules/@amplitude/analytics-node/lib/esm/index.cjs');
|
4
|
+
const require$$0 = /* @__PURE__ */ _commonjsHelpers.getAugmentedNamespace(index);
|
5
|
+
module.exports = require$$0;
|
5
6
|
//# sourceMappingURL=index2.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/_virtual/index2.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
1
|
+
import { getAugmentedNamespace } from "./_commonjsHelpers.js";
|
2
|
+
import * as index from './../_node_modules/@amplitude/analytics-node/lib/esm/index.js';
|
3
|
+
const require$$0 = /* @__PURE__ */ getAugmentedNamespace(index);
|
2
4
|
export {
|
3
|
-
|
5
|
+
require$$0 as default
|
4
6
|
};
|
5
7
|
//# sourceMappingURL=index2.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/_virtual/index3.cjs
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
module.exports = require$$0;
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
var crossSpawn = { exports: {} };
|
4
|
+
exports.__module = crossSpawn;
|
6
5
|
//# sourceMappingURL=index3.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/_virtual/index3.js
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
import * as index from './../_node_modules/@amplitude/analytics-node/lib/esm/index.js';
|
3
|
-
const require$$0 = /* @__PURE__ */ getAugmentedNamespace(index);
|
1
|
+
var crossSpawn = { exports: {} };
|
4
2
|
export {
|
5
|
-
|
3
|
+
crossSpawn as __module
|
6
4
|
};
|
7
5
|
//# sourceMappingURL=index3.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
@@ -228,7 +228,8 @@ const InferSliceResponse = index.default.object({
|
|
228
228
|
message: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`
|
229
229
|
});
|
230
230
|
return index.default.NEVER;
|
231
|
-
})
|
231
|
+
}),
|
232
|
+
langSmithUrl: index.default.string().url().optional()
|
232
233
|
});
|
233
234
|
exports.CustomTypesManager = CustomTypesManager;
|
234
235
|
//# sourceMappingURL=CustomTypesManager.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n});\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","SharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,QAAAC,QAAA,IAAWC,iBAAAA,iBACxBC,aAAE,KAAK;AAAA,MACN,KAAKA,aAAE,MAAMA,aAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAE;AAAA,MACvB,QAAAF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/CD,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,MA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ACD;AAAA,IAAA,CACD;AAEM,WAAA,MAAM,OAAO;EACrB;AAAA,EAEA,MAAM,WAAW,EAChB,YAGA;AACA,UAAM,YAAY,MAAM,KAAK,KAAK,uBAAsB;AACxD,UAAM,UAAU;AAAA,MACf,eAAe,UAAU;AAAA,IAAA;AAG1B,UAAM,aAAa,MAAM,KAAK,QAAQ,0BAAyB;AACzD,UAAA,eAAe,IAAI,gBAAgB;AAAA,MACxC;AAAA,IAAA,CACA;AAED,UAAM,MAAM,IAAI,IAAI,kBAAkBF,4BAAc,iBAAiB;AACjE,QAAA,SAAS,aAAa;AAE1B,UAAM,WAAW,MAAMC,MAAAA,QAAM,IAAI,YAAY;AAAA,MAC5C,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,UAAU;AAAA,IAAA,CACjC;AAEG,QAAA,CAAC,SAAS,IAAI;AACjB,YAAM,IAAI,MAAM,0BAA0B,SAAS,YAAY;AAAA,IAChE;AAEM,UAAA,OAAO,MAAM,SAAS;AAErB,WAAA,mBAAmB,MAAM,IAAI;AAAA,EACrC;AACA;AAID,MAAM,qBAAqBG,cAAE,OAAO;AAAA,EACnC,OAAOA,MAAE,QAAA,OAAA,EAAS,UAAU,CAAC,OAAO,QAAO;AACpC,UAAA,SAASC,YAAAA,YAAY,OAAO,KAAK;AACnC,QAAA,OAAO,SAAS,SAAS;AAC5B,aAAO,OAAO;AAAA,IACf;AACA,QAAI,SAAS;AAAA,MACZ,MAAMD,MAAAA,QAAE,aAAa;AAAA,MACrB,SAAS,yBAAyB,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IAAA,CAC/D;AAED,WAAOA,MAAAA,QAAE;AAAA,EAAA,CACT;AACD,CAAA;;"}
|
1
|
+
{"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","SharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,QAAAC,QAAA,IAAWC,iBAAAA,iBACxBC,aAAE,KAAK;AAAA,MACN,KAAKA,aAAE,MAAMA,aAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAE;AAAA,MACvB,QAAAF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/CD,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,MAAsD;AAAA,MAC3D,QAAQ,CAAE;AAAA,MACV,QAAQ,CAAE;AAAA,IAAA;AAGX,UAAM,EAAE,KAAK,QAAAC,QAAA,IAAW,MAAM,KAAK,sBAAqB;AACxD,QAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAGA,OAAM;AAEtC,QAAI,KAAK;AACR,iBAAW,MAAM,KAAK;AACf,cAAA,EAAE,OAAO,QAAAA,aAAW,MAAM,KAAK,eAAe,EAAE,GAAA,CAAI;AAC1D,YAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAGA,QAAM;AAEtC,YAAI,UAAU,CAAC,QAAQ,KAAK,WAAW,MAAM,SAAS;AACrD,cAAI,OAAO,KAAK,EAAE,MAAO,CAAA;AAAA,QAC1B;AAAA,MACD;AAAA,IACD;AAEO,WAAA;AAAA,EACR;AAAA,EAEA,MAAM,iBACL,MAA8B;AAE9BD,sDAAyB,KAAK,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B,SAAS,YAAY;AAAA,IAChE;AAEM,UAAA,OAAO,MAAM,SAAS;AAErB,WAAA,mBAAmB,MAAM,IAAI;AAAA,EACrC;AACA;AAID,MAAM,qBAAqBG,cAAE,OAAO;AAAA,EACnC,OAAOA,MAAE,QAAA,OAAA,EAAS,UAAU,CAAC,OAAO,QAAO;AACpC,UAAA,SAASC,YAAAA,YAAY,OAAO,KAAK;AACnC,QAAA,OAAO,SAAS,SAAS;AAC5B,aAAO,OAAO;AAAA,IACf;AACA,QAAI,SAAS;AAAA,MACZ,MAAMD,MAAAA,QAAE,aAAa;AAAA,MACrB,SAAS,yBAAyB,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IAAA,CAC/D;AAED,WAAOA,MAAAA,QAAE;AAAA,EAAA,CACT;AAAA,EACD,cAAcA,MAAAA,QAAE,OAAS,EAAA,IAAA,EAAM,SAAU;AACzC,CAAA;;"}
|
@@ -776,6 +776,7 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
776
776
|
[x: string]: string;
|
777
777
|
} | undefined;
|
778
778
|
}, unknown>;
|
779
|
+
langSmithUrl: z.ZodOptional<z.ZodString>;
|
779
780
|
}, "strip", z.ZodTypeAny, {
|
780
781
|
slice: {
|
781
782
|
id: string;
|
@@ -1489,7 +1490,9 @@ declare const InferSliceResponse: z.ZodObject<{
|
|
1489
1490
|
[x: string]: string;
|
1490
1491
|
} | undefined;
|
1491
1492
|
};
|
1493
|
+
langSmithUrl?: string | undefined;
|
1492
1494
|
}, {
|
1493
1495
|
slice?: unknown;
|
1496
|
+
langSmithUrl?: string | undefined;
|
1494
1497
|
}>;
|
1495
1498
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CustomTypesManager.js","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n});\n"],"names":["errors"],"mappings":";;;;;;;;;;;AAoFM,MAAO,2BAA2B,YAAW;A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AyB,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IAAA,CAC/D;AAED,WAAO,EAAE;AAAA,EAAA,CACT;AACD,CAAA;"}
|
1
|
+
{"version":3,"file":"CustomTypesManager.js","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n"],"names":["errors"],"mappings":";;;;;;;;;;;AAoFM,MAAO,2BAA2B,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1B,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,OAAA,IAAW,iBACxB,EAAE,KAAK;AAAA,MACN,KAAK,EAAE,MAAM,EAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAE;AAAA,MACvB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/C,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,MAAsD;AAAA,MAC3D,QAAQ,CAAE;AAAA,MACV,QAAQ,CAAE;AAAA,IAAA;AAGX,UAAM,EAAE,KAAK,OAAA,IAAW,MAAM,KAAK,sBAAqB;AACxD,QAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAG,MAAM;AAEtC,QAAI,KAAK;AACR,iBAAW,MAAM,KAAK;AACf,cAAA,EAAE,OAAO,QAAAA,YAAW,MAAM,KAAK,eAAe,EAAE,GAAA,CAAI;AAC1D,YAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAGA,OAAM;AAEtC,YAAI,UAAU,CAAC,QAAQ,KAAK,WAAW,MAAM,SAAS;AACrD,cAAI,OAAO,KAAK,EAAE,MAAO,CAAA;AAAA,QAC1B;AAAA,MACD;AAAA,IACD;A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,OAAO,MAAM,SAAS;AAErB,WAAA,mBAAmB,MAAM,IAAI;AAAA,EACrC;AACA;AAID,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACnC,OAAO,EAAE,OAAA,EAAS,UAAU,CAAC,OAAO,QAAO;AACpC,UAAA,SAAS,YAAY,OAAO,KAAK;AACnC,QAAA,OAAO,SAAS,SAAS;AAC5B,aAAO,OAAO;AAAA,IACf;AACA,QAAI,SAAS;AAAA,MACZ,MAAM,EAAE,aAAa;AAAA,MACrB,SAAS,yBAAyB,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IAAA,CAC/D;AAED,WAAO,EAAE;AAAA,EAAA,CACT;AAAA,EACD,cAAc,EAAE,OAAS,EAAA,IAAA,EAAM,SAAU;AACzC,CAAA;"}
|
@@ -38,7 +38,8 @@ const SegmentEventType = {
|
|
38
38
|
sharedOnboarding_step_opened: "shared-onboarding:step-opened",
|
39
39
|
sharedOnboarding_step_completed: "shared-onboarding:step-completed",
|
40
40
|
sharedOnboarding_completed: "shared-onboarding:completed",
|
41
|
-
sharedOnboarding_tutorial: "shared-onboarding:follow-tutorial"
|
41
|
+
sharedOnboarding_tutorial: "shared-onboarding:follow-tutorial",
|
42
|
+
sliceGenerationFeedback: "slice-generation-feedback"
|
42
43
|
};
|
43
44
|
const HumanSegmentEventType = {
|
44
45
|
[SegmentEventType.command_init_start]: "SliceMachine Init Start",
|
@@ -78,7 +79,8 @@ const HumanSegmentEventType = {
|
|
78
79
|
[SegmentEventType.sharedOnboarding_step_completed]: "Prismic Onboarding Guide Step Completed",
|
79
80
|
[SegmentEventType.sharedOnboarding_step_opened]: "Prismic Onboarding Guide Step Open",
|
80
81
|
[SegmentEventType.sharedOnboarding_completed]: "Prismic Onboarding Guide Completed",
|
81
|
-
[SegmentEventType.sharedOnboarding_tutorial]: "Prismic Onboarding Guide Follow Tutorial"
|
82
|
+
[SegmentEventType.sharedOnboarding_tutorial]: "Prismic Onboarding Guide Follow Tutorial",
|
83
|
+
[SegmentEventType.sliceGenerationFeedback]: "Slice Generation Feedback"
|
82
84
|
};
|
83
85
|
exports.HumanSegmentEventType = HumanSegmentEventType;
|
84
86
|
exports.SegmentEventType = SegmentEventType;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.cjs","sources":["../../../../src/managers/telemetry/types.ts"],"sourcesContent":["import { FieldType } from \"@prismicio/types-internal/lib/customtypes/widgets\";\n\nimport { CustomTypeFormat } from \"../customTypes/types\";\nimport type { PushChangesLimitType } from \"../prismicRepository/types\";\n\nexport type { Variant } from \"@amplitude/experiment-node-server\";\n\nexport const SegmentEventType = {\n\tcommand_init_start: \"command:init:start\",\n\tcommand_init_identify: \"command:init:identify\",\n\tcommand_init_end: \"command:init:end\",\n\treview: \"review\",\n\tsliceSimulator_open: \"slice-simulator:open\",\n\tsliceSimulator_isNotRunning: \"slice-simulator:is-not-running\",\n\tpageView: \"page-view\",\n\topenVideoTutorials: \"open-video-tutorials\",\n\tfield_added: \"field:added\",\n\tfield_updated: \"field:updated\",\n\tfield_settingsOpened: \"field:settings-opened\",\n\tcustomType_created: \"custom-type:created\",\n\tcustomType_sliceZoneUpdated: \"custom-type:slice-zone-updated\",\n\tcustomType_openAddFromTemplates: \"custom-type:open-add-from-templates\",\n\tcustomType_saved: \"custom-type:saved\",\n\tslice_created: \"slice:created\",\n\tlegacySlice_converted: \"legacy-slice:converted\",\n\tscreenshotTaken: \"screenshot-taken\",\n\tchanges_pushed: \"changes:pushed\",\n\tchanges_groupPushed: \"changes:group-pushed\",\n\tchanges_limitReach: \"changes:limit-reach\",\n\teditor_widgetUsed: \"editor:widget-used\",\n\topen_page_snippet: \"page-type:open-snippet\",\n\tcopy_page_snippet: \"page-type:copy-snippet\",\n\tswitch_environment: \"environment:switch\",\n\tdevCollab_joinBetaClicked: \"dev-collab:join-beta-clicked\",\n\tdevCollab_setUpWorkflowOpened: \"dev-collab:set-up-workflow-opened\",\n\tdevCollab_workflowStubDisplayed: \"dev-collab:workflow-stub-displayed\",\n\tsliceMachine_start: \"slice-machine:start\",\n\tsliceLibrary_beta_modalOpened: \"slice-library:beta:modal-opened\",\n\tsliceLibrary_beta_codeOpened: \"slice-library:beta:code-opened\",\n\tpostPush_emptyStateCtaClicked: \"post-push:empty-state-cta-clicked\",\n\tpostPush_toastCtaClicked: \"post-push:toast-cta-clicked\",\n\texperiment_exposure: \"experiment:exposure\",\n\tsharedOnboarding_step_opened: \"shared-onboarding:step-opened\",\n\tsharedOnboarding_step_completed: \"shared-onboarding:step-completed\",\n\tsharedOnboarding_completed: \"shared-onboarding:completed\",\n\tsharedOnboarding_tutorial: \"shared-onboarding:follow-tutorial\",\n} as const;\ntype SegmentEventTypes =\n\t(typeof SegmentEventType)[keyof typeof SegmentEventType];\n\nexport const HumanSegmentEventType = {\n\t[SegmentEventType.command_init_start]: \"SliceMachine Init Start\",\n\t[SegmentEventType.command_init_identify]: \"SliceMachine Init Identify\",\n\t[SegmentEventType.command_init_end]: \"SliceMachine Init End\",\n\t[SegmentEventType.review]: \"SliceMachine Review\",\n\t[SegmentEventType.sliceSimulator_open]: \"SliceMachine Slice Simulator Open\",\n\t[SegmentEventType.sliceSimulator_isNotRunning]:\n\t\t\"SliceMachine Slice Simulator is not running\",\n\t[SegmentEventType.pageView]: \"SliceMachine Page View\",\n\t[SegmentEventType.openVideoTutorials]: \"SliceMachine Open Video Tutorials\",\n\t[SegmentEventType.field_added]: \"SliceMachine Field Added\",\n\t[SegmentEventType.field_updated]: \"SliceMachine Field Updated\",\n\t[SegmentEventType.field_settingsOpened]: \"SliceMachine Field Settings Opened\",\n\t[SegmentEventType.customType_created]: \"SliceMachine Custom Type Created\",\n\t[SegmentEventType.customType_sliceZoneUpdated]:\n\t\t\"SliceMachine Slicezone Updated\",\n\t[SegmentEventType.customType_openAddFromTemplates]:\n\t\t\"SliceMachine Open Add from templates\",\n\t[SegmentEventType.customType_saved]: \"SliceMachine Custom Type Saved\",\n\t[SegmentEventType.slice_created]: \"SliceMachine Slice Created\",\n\t[SegmentEventType.legacySlice_converted]:\n\t\t\"SliceMachine Legacy Slice Converted\",\n\t[SegmentEventType.screenshotTaken]: \"SliceMachine Screenshot Taken\",\n\t[SegmentEventType.changes_pushed]: \"SliceMachine Changes Pushed\",\n\t[SegmentEventType.changes_groupPushed]: \"SliceMachine Group Field Pushed\",\n\t[SegmentEventType.changes_limitReach]: \"SliceMachine Changes Limit Reach\",\n\t[SegmentEventType.editor_widgetUsed]: \"SliceMachine Editor Widget Used\",\n\t[SegmentEventType.open_page_snippet]:\n\t\t\"SliceMachine Opens Page Type Snippet Dialog\",\n\t[SegmentEventType.copy_page_snippet]:\n\t\t\"Slice Machine page code snippet copied\",\n\t[SegmentEventType.switch_environment]: \"SliceMachine environment switch\",\n\t[SegmentEventType.devCollab_joinBetaClicked]:\n\t\t\"SliceMachine Dev Collab Join Beta Clicked\",\n\t[SegmentEventType.devCollab_setUpWorkflowOpened]:\n\t\t\"SliceMachine Dev Collab Set Up Workflow Opened\",\n\t[SegmentEventType.devCollab_workflowStubDisplayed]:\n\t\t\"SliceMachine Dev Collab Workflow Stub Displayed\",\n\t[SegmentEventType.sliceMachine_start]: \"SliceMachine Start\",\n\t[SegmentEventType.sliceLibrary_beta_modalOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA modal displayed\",\n\t[SegmentEventType.sliceLibrary_beta_codeOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA example code opened\",\n\t[SegmentEventType.postPush_emptyStateCtaClicked]:\n\t\t\"SliceMachine Post Push Empty State CTA Clicked\",\n\t[SegmentEventType.postPush_toastCtaClicked]:\n\t\t\"SliceMachine Post Push Toast CTA Clicked\",\n\t[SegmentEventType.experiment_exposure]: \"$exposure\",\n\t[SegmentEventType.sharedOnboarding_step_completed]:\n\t\t\"Prismic Onboarding Guide Step Completed\",\n\t[SegmentEventType.sharedOnboarding_step_opened]:\n\t\t\"Prismic Onboarding Guide Step Open\",\n\t[SegmentEventType.sharedOnboarding_completed]:\n\t\t\"Prismic Onboarding Guide Completed\",\n\t[SegmentEventType.sharedOnboarding_tutorial]:\n\t\t\"Prismic Onboarding Guide Follow Tutorial\",\n} as const;\n\nexport type HumanSegmentEventTypes =\n\t(typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];\n\ntype SegmentEvent<\n\tTType extends SegmentEventTypes,\n\tTProperties extends Record<string, unknown> | void = void,\n> = TProperties extends void\n\t? {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t }\n\t: {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t } & TProperties;\n\ntype CommandInitStartSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_start\n>;\n\n// This event feels off, we have a dedicated `identify` method...\ntype CommandInitIdentifySegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_identify\n>;\n\ntype CommandInitEndSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_end,\n\t{ framework: string; success: boolean; error?: string }\n>;\n\ntype ReviewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.review,\n\t{\n\t\trating: number;\n\t\tcomment: string;\n\t\ttype: \"onboarding\";\n\t}\n>;\n\ntype SliceSimulatorOpenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_open\n>;\n\ntype SliceSimulatorIsNotRunningSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_isNotRunning\n>;\n\ntype PageViewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.pageView,\n\t{\n\t\turl: string;\n\t\tpath: string;\n\t\tsearch: string;\n\t\ttitle: string;\n\t\treferrer: string;\n\t\tadapter: string;\n\t\t/*\n\t\t * We are tracking outer sizes instead of inner sizes as with the latter, we\n\t\t * can't differentiate between users with a high-density screen and those\n\t\t * zooming in/out with ⌘ + / ⌘ -. Indeed, when users zoom in/out, some\n\t\t * browsers (like Google Chrome) will update `window.devicePixelRatio` while\n\t\t * others (like Safari) will keep it unchanged so that it always reflects\n\t\t * the ratio of physical pixels to CSS pixels.\n\t\t */\n\t\touterWidth: number;\n\t\touterHeight: number;\n\t\tscreenWidth: number;\n\t\tscreenHeight: number;\n\t}\n>;\n\ntype OpenPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.open_page_snippet,\n\t{ framework: string }\n>;\n\ntype CopyPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.copy_page_snippet,\n\t{ framework: string }\n>;\n\ntype SwitchEnvironmentSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.switch_environment,\n\t{ domain: string }\n>;\n\ntype OpenVideoTutorialsSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.openVideoTutorials,\n\t{ video: string }\n>;\n\ntype FieldAddedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_added,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_updated,\n\t{\n\t\tpreviousId: string;\n\t\tid: string;\n\t\tidUpdated: boolean;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldSettingsOpenedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_settingsOpened,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t}\n>;\n\ntype CustomTypeCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t\torigin: \"onboarding\" | \"table\";\n\t}\n>;\n\ntype CustomTypeSliceZoneUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_sliceZoneUpdated,\n\t{ customTypeId: string }\n>;\n\ntype CustomTypeOpenAddFromTemplatesEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_openAddFromTemplates,\n\t{ customTypeId: string; customTypeFormat: CustomTypeFormat }\n>;\n\ntype CustomTypeSavedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_saved,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t}\n>;\n\ntype SliceCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.slice_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tlibrary: string;\n\t\tlocation: \"custom_type\" | \"page_type\" | \"slices\";\n\t} & (\n\t\t| { mode: \"ai\" }\n\t\t| { mode: \"manual\" }\n\t\t| { mode: \"template\"; sliceTemplate: string }\n\t)\n>;\n\ntype LegacySliceConvertedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.legacySlice_converted,\n\t{\n\t\tid: string;\n\t\tvariation: string;\n\t\tlibrary: string;\n\t\tconversionType:\n\t\t\t| \"as_new_slice\"\n\t\t\t| \"as_new_variation\"\n\t\t\t| \"merge_with_identical\";\n\t}\n>;\n\ntype ScreenshotTakenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.screenshotTaken,\n\t{\n\t\ttype: \"custom\";\n\t\tmethod: \"upload\" | \"dragAndDrop\";\n\t}\n>;\n\ntype ChangesPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_pushed,\n\t{\n\t\tcustomTypesCreated: number;\n\t\tcustomTypesModified: number;\n\t\tcustomTypesDeleted: number;\n\t\tslicesCreated: number;\n\t\tslicesModified: number;\n\t\tslicesDeleted: number;\n\t\tmissingScreenshots: number;\n\t\ttotal: number;\n\t\tduration: number;\n\t\thasDeletedDocuments: boolean;\n\t}\n>;\n\ntype ChangesGroupPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_groupPushed,\n\t{\n\t\tisInStaticZone: boolean;\n\t\tisInSlice: boolean;\n\t} & {\n\t\t[key in FieldType]?: number;\n\t}\n>;\n\ntype ChangesLimitReachSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_limitReach,\n\t{ limitType: PushChangesLimitType }\n>;\n\ntype EditorWidgetUsedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.editor_widgetUsed,\n\t{ sliceId: string }\n>;\n\ntype DevCollabJoinBetaClicked = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_joinBetaClicked\n>;\n\ntype DevCollabSetUpWorkflowOpened = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_setUpWorkflowOpened\n>;\n\ntype DevCollabWorkflowStubDisplayed = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_workflowStubDisplayed\n>;\n\ntype SliceMachineStart = SegmentEvent<\n\ttypeof SegmentEventType.sliceMachine_start,\n\t{\n\t\tadapter?: string;\n\t\tadapterVersion?: string;\n\t\tgitProvider?: string;\n\t\tisAdapterUpdateAvailable?: boolean;\n\t\tisLoggedIn?: boolean;\n\t\tisSliceMachineUpdateAvailable?: boolean;\n\t\tisTypeScriptProject?: boolean;\n\t\tnodeVersion?: string;\n\t\tnumberOfCustomTypes?: number;\n\t\tnumberOfSlices?: number;\n\t\tosPlatform?: string;\n\t\tpackageManager?: string;\n\t\tprojectPort?: string;\n\t\tsliceMachineVersion?: string;\n\t\tversionControlSystem?: string;\n\t}\n>;\n\ntype SliceLibraryBetaModalOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_modalOpened\n>;\n\ntype SliceLibraryBetaCodeOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_codeOpened\n>;\n\ntype OnboardingCommonPayload = { stepId: string; stepTitle: string };\ntype SharedOnboardingProperties<T = Record<string, string>> = T & {\n\tsource: \"SliceMachine\";\n};\n\ntype SliceMachineSharedOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_opened,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_completed,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_completed,\n\tSharedOnboardingProperties\n>;\ntype SliceMachineSharedOnboardingTutorial = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_tutorial,\n\tSharedOnboardingProperties\n>;\ntype SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_emptyStateCtaClicked\n>;\n\ntype SliceMachinePostPushToastCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_toastCtaClicked\n>;\n\ntype SliceMachineExperimentExposure = SegmentEvent<\n\ttypeof SegmentEventType.experiment_exposure,\n\t{\n\t\tflag_key: string;\n\t\tvariant: string;\n\t}\n>;\n\nexport type SegmentEvents =\n\t| CommandInitStartSegmentEvent\n\t| CommandInitIdentifySegmentEvent\n\t| CommandInitEndSegmentEvent\n\t| ReviewSegmentEvent\n\t| SliceSimulatorOpenSegmentEvent\n\t| SliceSimulatorIsNotRunningSegmentEvent\n\t| PageViewSegmentEvent\n\t| OpenVideoTutorialsSegmentEvent\n\t| FieldAddedSegmentEvent\n\t| FieldUpdatedSegmentEvent\n\t| FieldSettingsOpenedSegmentEvent\n\t| CustomTypeCreatedSegmentEvent\n\t| CustomTypeSliceZoneUpdatedSegmentEvent\n\t| CustomTypeOpenAddFromTemplatesEvent\n\t| CustomTypeSavedSegmentEvent\n\t| SliceCreatedSegmentEvent\n\t| LegacySliceConvertedSegmentEvent\n\t| ScreenshotTakenSegmentEvent\n\t| ChangesPushedSegmentEvent\n\t| ChangesGroupPushedSegmentEvent\n\t| ChangesLimitReachSegmentEvent\n\t| EditorWidgetUsedSegmentEvent\n\t| OpenPageSnippetSegmentEvent\n\t| CopyPageSnippetSegmentEvent\n\t| SwitchEnvironmentSegmentEvent\n\t| DevCollabJoinBetaClicked\n\t| DevCollabSetUpWorkflowOpened\n\t| DevCollabWorkflowStubDisplayed\n\t| SliceMachineStart\n\t| SliceLibraryBetaModalOpened\n\t| SliceLibraryBetaCodeOpened\n\t| SliceMachineSharedOnboardingStepOpened\n\t| SliceMachineSharedOnboardingStepCompleted\n\t| SliceMachineSharedOnboardingCompleted\n\t| SliceMachineSharedOnboardingTutorial\n\t| SliceMachinePostPushEmptyStateCtaClicked\n\t| SliceMachinePostPushToastCtaClicked\n\t| SliceMachineExperimentExposure;\n"],"names":[],"mappings":";;AAOO,MAAM,mBAAmB;AAAA,EAC/B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,+BAA+B;AAAA,EAC/B,iCAAiC;AAAA,EACjC,oBAAoB;AAAA,EACpB,+BAA+B;AAAA,EAC/B,8BAA8B;AAAA,EAC9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B,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,wBAAwB,GACzC;AAAA,EACD,CAAC,iBAAiB,mBAAmB,GAAG;AAAA,EACxC,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,0BAA0B,GAC3C;AAAA,EACD,CAAC,iBAAiB,yBAAyB,GAC1C;;;;"}
|
1
|
+
{"version":3,"file":"types.cjs","sources":["../../../../src/managers/telemetry/types.ts"],"sourcesContent":["import { FieldType } from \"@prismicio/types-internal/lib/customtypes/widgets\";\n\nimport { CustomTypeFormat } from \"../customTypes/types\";\nimport type { PushChangesLimitType } from \"../prismicRepository/types\";\n\nexport type { Variant } from \"@amplitude/experiment-node-server\";\n\nexport const SegmentEventType = {\n\tcommand_init_start: \"command:init:start\",\n\tcommand_init_identify: \"command:init:identify\",\n\tcommand_init_end: \"command:init:end\",\n\treview: \"review\",\n\tsliceSimulator_open: \"slice-simulator:open\",\n\tsliceSimulator_isNotRunning: \"slice-simulator:is-not-running\",\n\tpageView: \"page-view\",\n\topenVideoTutorials: \"open-video-tutorials\",\n\tfield_added: \"field:added\",\n\tfield_updated: \"field:updated\",\n\tfield_settingsOpened: \"field:settings-opened\",\n\tcustomType_created: \"custom-type:created\",\n\tcustomType_sliceZoneUpdated: \"custom-type:slice-zone-updated\",\n\tcustomType_openAddFromTemplates: \"custom-type:open-add-from-templates\",\n\tcustomType_saved: \"custom-type:saved\",\n\tslice_created: \"slice:created\",\n\tlegacySlice_converted: \"legacy-slice:converted\",\n\tscreenshotTaken: \"screenshot-taken\",\n\tchanges_pushed: \"changes:pushed\",\n\tchanges_groupPushed: \"changes:group-pushed\",\n\tchanges_limitReach: \"changes:limit-reach\",\n\teditor_widgetUsed: \"editor:widget-used\",\n\topen_page_snippet: \"page-type:open-snippet\",\n\tcopy_page_snippet: \"page-type:copy-snippet\",\n\tswitch_environment: \"environment:switch\",\n\tdevCollab_joinBetaClicked: \"dev-collab:join-beta-clicked\",\n\tdevCollab_setUpWorkflowOpened: \"dev-collab:set-up-workflow-opened\",\n\tdevCollab_workflowStubDisplayed: \"dev-collab:workflow-stub-displayed\",\n\tsliceMachine_start: \"slice-machine:start\",\n\tsliceLibrary_beta_modalOpened: \"slice-library:beta:modal-opened\",\n\tsliceLibrary_beta_codeOpened: \"slice-library:beta:code-opened\",\n\tpostPush_emptyStateCtaClicked: \"post-push:empty-state-cta-clicked\",\n\tpostPush_toastCtaClicked: \"post-push:toast-cta-clicked\",\n\texperiment_exposure: \"experiment:exposure\",\n\tsharedOnboarding_step_opened: \"shared-onboarding:step-opened\",\n\tsharedOnboarding_step_completed: \"shared-onboarding:step-completed\",\n\tsharedOnboarding_completed: \"shared-onboarding:completed\",\n\tsharedOnboarding_tutorial: \"shared-onboarding:follow-tutorial\",\n\tsliceGenerationFeedback: \"slice-generation-feedback\",\n} as const;\ntype SegmentEventTypes =\n\t(typeof SegmentEventType)[keyof typeof SegmentEventType];\n\nexport const HumanSegmentEventType = {\n\t[SegmentEventType.command_init_start]: \"SliceMachine Init Start\",\n\t[SegmentEventType.command_init_identify]: \"SliceMachine Init Identify\",\n\t[SegmentEventType.command_init_end]: \"SliceMachine Init End\",\n\t[SegmentEventType.review]: \"SliceMachine Review\",\n\t[SegmentEventType.sliceSimulator_open]: \"SliceMachine Slice Simulator Open\",\n\t[SegmentEventType.sliceSimulator_isNotRunning]:\n\t\t\"SliceMachine Slice Simulator is not running\",\n\t[SegmentEventType.pageView]: \"SliceMachine Page View\",\n\t[SegmentEventType.openVideoTutorials]: \"SliceMachine Open Video Tutorials\",\n\t[SegmentEventType.field_added]: \"SliceMachine Field Added\",\n\t[SegmentEventType.field_updated]: \"SliceMachine Field Updated\",\n\t[SegmentEventType.field_settingsOpened]: \"SliceMachine Field Settings Opened\",\n\t[SegmentEventType.customType_created]: \"SliceMachine Custom Type Created\",\n\t[SegmentEventType.customType_sliceZoneUpdated]:\n\t\t\"SliceMachine Slicezone Updated\",\n\t[SegmentEventType.customType_openAddFromTemplates]:\n\t\t\"SliceMachine Open Add from templates\",\n\t[SegmentEventType.customType_saved]: \"SliceMachine Custom Type Saved\",\n\t[SegmentEventType.slice_created]: \"SliceMachine Slice Created\",\n\t[SegmentEventType.legacySlice_converted]:\n\t\t\"SliceMachine Legacy Slice Converted\",\n\t[SegmentEventType.screenshotTaken]: \"SliceMachine Screenshot Taken\",\n\t[SegmentEventType.changes_pushed]: \"SliceMachine Changes Pushed\",\n\t[SegmentEventType.changes_groupPushed]: \"SliceMachine Group Field Pushed\",\n\t[SegmentEventType.changes_limitReach]: \"SliceMachine Changes Limit Reach\",\n\t[SegmentEventType.editor_widgetUsed]: \"SliceMachine Editor Widget Used\",\n\t[SegmentEventType.open_page_snippet]:\n\t\t\"SliceMachine Opens Page Type Snippet Dialog\",\n\t[SegmentEventType.copy_page_snippet]:\n\t\t\"Slice Machine page code snippet copied\",\n\t[SegmentEventType.switch_environment]: \"SliceMachine environment switch\",\n\t[SegmentEventType.devCollab_joinBetaClicked]:\n\t\t\"SliceMachine Dev Collab Join Beta Clicked\",\n\t[SegmentEventType.devCollab_setUpWorkflowOpened]:\n\t\t\"SliceMachine Dev Collab Set Up Workflow Opened\",\n\t[SegmentEventType.devCollab_workflowStubDisplayed]:\n\t\t\"SliceMachine Dev Collab Workflow Stub Displayed\",\n\t[SegmentEventType.sliceMachine_start]: \"SliceMachine Start\",\n\t[SegmentEventType.sliceLibrary_beta_modalOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA modal displayed\",\n\t[SegmentEventType.sliceLibrary_beta_codeOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA example code opened\",\n\t[SegmentEventType.postPush_emptyStateCtaClicked]:\n\t\t\"SliceMachine Post Push Empty State CTA Clicked\",\n\t[SegmentEventType.postPush_toastCtaClicked]:\n\t\t\"SliceMachine Post Push Toast CTA Clicked\",\n\t[SegmentEventType.experiment_exposure]: \"$exposure\",\n\t[SegmentEventType.sharedOnboarding_step_completed]:\n\t\t\"Prismic Onboarding Guide Step Completed\",\n\t[SegmentEventType.sharedOnboarding_step_opened]:\n\t\t\"Prismic Onboarding Guide Step Open\",\n\t[SegmentEventType.sharedOnboarding_completed]:\n\t\t\"Prismic Onboarding Guide Completed\",\n\t[SegmentEventType.sharedOnboarding_tutorial]:\n\t\t\"Prismic Onboarding Guide Follow Tutorial\",\n\t[SegmentEventType.sliceGenerationFeedback]: \"Slice Generation Feedback\",\n} as const;\n\nexport type HumanSegmentEventTypes =\n\t(typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];\n\ntype SegmentEvent<\n\tTType extends SegmentEventTypes,\n\tTProperties extends Record<string, unknown> | void = void,\n> = TProperties extends void\n\t? {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t }\n\t: {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t } & TProperties;\n\ntype CommandInitStartSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_start\n>;\n\n// This event feels off, we have a dedicated `identify` method...\ntype CommandInitIdentifySegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_identify\n>;\n\ntype CommandInitEndSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_end,\n\t{ framework: string; success: boolean; error?: string }\n>;\n\ntype ReviewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.review,\n\t{\n\t\trating: number;\n\t\tcomment: string;\n\t\ttype: \"onboarding\";\n\t}\n>;\n\ntype SliceSimulatorOpenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_open\n>;\n\ntype SliceSimulatorIsNotRunningSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_isNotRunning\n>;\n\ntype PageViewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.pageView,\n\t{\n\t\turl: string;\n\t\tpath: string;\n\t\tsearch: string;\n\t\ttitle: string;\n\t\treferrer: string;\n\t\tadapter: string;\n\t\t/*\n\t\t * We are tracking outer sizes instead of inner sizes as with the latter, we\n\t\t * can't differentiate between users with a high-density screen and those\n\t\t * zooming in/out with ⌘ + / ⌘ -. Indeed, when users zoom in/out, some\n\t\t * browsers (like Google Chrome) will update `window.devicePixelRatio` while\n\t\t * others (like Safari) will keep it unchanged so that it always reflects\n\t\t * the ratio of physical pixels to CSS pixels.\n\t\t */\n\t\touterWidth: number;\n\t\touterHeight: number;\n\t\tscreenWidth: number;\n\t\tscreenHeight: number;\n\t}\n>;\n\ntype OpenPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.open_page_snippet,\n\t{ framework: string }\n>;\n\ntype CopyPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.copy_page_snippet,\n\t{ framework: string }\n>;\n\ntype SwitchEnvironmentSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.switch_environment,\n\t{ domain: string }\n>;\n\ntype OpenVideoTutorialsSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.openVideoTutorials,\n\t{ video: string }\n>;\n\ntype FieldAddedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_added,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_updated,\n\t{\n\t\tpreviousId: string;\n\t\tid: string;\n\t\tidUpdated: boolean;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldSettingsOpenedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_settingsOpened,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t}\n>;\n\ntype CustomTypeCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t\torigin: \"onboarding\" | \"table\";\n\t}\n>;\n\ntype CustomTypeSliceZoneUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_sliceZoneUpdated,\n\t{ customTypeId: string }\n>;\n\ntype CustomTypeOpenAddFromTemplatesEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_openAddFromTemplates,\n\t{ customTypeId: string; customTypeFormat: CustomTypeFormat }\n>;\n\ntype CustomTypeSavedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_saved,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t}\n>;\n\ntype SliceCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.slice_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tlibrary: string;\n\t\tlocation: \"custom_type\" | \"page_type\" | \"slices\";\n\t} & (\n\t\t| { mode: \"ai\"; langSmithUrl?: string }\n\t\t| { mode: \"manual\" }\n\t\t| { mode: \"template\"; sliceTemplate: string }\n\t)\n>;\n\ntype LegacySliceConvertedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.legacySlice_converted,\n\t{\n\t\tid: string;\n\t\tvariation: string;\n\t\tlibrary: string;\n\t\tconversionType:\n\t\t\t| \"as_new_slice\"\n\t\t\t| \"as_new_variation\"\n\t\t\t| \"merge_with_identical\";\n\t}\n>;\n\ntype ScreenshotTakenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.screenshotTaken,\n\t{\n\t\ttype: \"custom\";\n\t\tmethod: \"upload\" | \"dragAndDrop\";\n\t}\n>;\n\ntype ChangesPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_pushed,\n\t{\n\t\tcustomTypesCreated: number;\n\t\tcustomTypesModified: number;\n\t\tcustomTypesDeleted: number;\n\t\tslicesCreated: number;\n\t\tslicesModified: number;\n\t\tslicesDeleted: number;\n\t\tmissingScreenshots: number;\n\t\ttotal: number;\n\t\tduration: number;\n\t\thasDeletedDocuments: boolean;\n\t}\n>;\n\ntype ChangesGroupPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_groupPushed,\n\t{\n\t\tisInStaticZone: boolean;\n\t\tisInSlice: boolean;\n\t} & {\n\t\t[key in FieldType]?: number;\n\t}\n>;\n\ntype ChangesLimitReachSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_limitReach,\n\t{ limitType: PushChangesLimitType }\n>;\n\ntype EditorWidgetUsedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.editor_widgetUsed,\n\t{ sliceId: string }\n>;\n\ntype DevCollabJoinBetaClicked = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_joinBetaClicked\n>;\n\ntype DevCollabSetUpWorkflowOpened = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_setUpWorkflowOpened\n>;\n\ntype DevCollabWorkflowStubDisplayed = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_workflowStubDisplayed\n>;\n\ntype SliceMachineStart = SegmentEvent<\n\ttypeof SegmentEventType.sliceMachine_start,\n\t{\n\t\tadapter?: string;\n\t\tadapterVersion?: string;\n\t\tgitProvider?: string;\n\t\tisAdapterUpdateAvailable?: boolean;\n\t\tisLoggedIn?: boolean;\n\t\tisSliceMachineUpdateAvailable?: boolean;\n\t\tisTypeScriptProject?: boolean;\n\t\tnodeVersion?: string;\n\t\tnumberOfCustomTypes?: number;\n\t\tnumberOfSlices?: number;\n\t\tosPlatform?: string;\n\t\tpackageManager?: string;\n\t\tprojectPort?: string;\n\t\tsliceMachineVersion?: string;\n\t\tversionControlSystem?: string;\n\t}\n>;\n\ntype SliceLibraryBetaModalOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_modalOpened\n>;\n\ntype SliceLibraryBetaCodeOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_codeOpened\n>;\n\ntype OnboardingCommonPayload = { stepId: string; stepTitle: string };\ntype SharedOnboardingProperties<T = Record<string, string>> = T & {\n\tsource: \"SliceMachine\";\n};\n\ntype SliceMachineSharedOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_opened,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_completed,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_completed,\n\tSharedOnboardingProperties\n>;\ntype SliceMachineSharedOnboardingTutorial = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_tutorial,\n\tSharedOnboardingProperties\n>;\ntype SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_emptyStateCtaClicked\n>;\n\ntype SliceMachinePostPushToastCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_toastCtaClicked\n>;\n\ntype SliceMachineExperimentExposure = SegmentEvent<\n\ttypeof SegmentEventType.experiment_exposure,\n\t{\n\t\tflag_key: string;\n\t\tvariant: string;\n\t}\n>;\n\ntype SliceGenerationFeedback = SegmentEvent<\n\ttypeof SegmentEventType.sliceGenerationFeedback,\n\t{\n\t\ttype: \"model\";\n\t\tsliceId: string;\n\t\tvariationId: string;\n\t\tfeedback: \"up\" | \"down\";\n\t\tlangSmithUrl?: string;\n\t}\n>;\n\nexport type SegmentEvents =\n\t| CommandInitStartSegmentEvent\n\t| CommandInitIdentifySegmentEvent\n\t| CommandInitEndSegmentEvent\n\t| ReviewSegmentEvent\n\t| SliceSimulatorOpenSegmentEvent\n\t| SliceSimulatorIsNotRunningSegmentEvent\n\t| PageViewSegmentEvent\n\t| OpenVideoTutorialsSegmentEvent\n\t| FieldAddedSegmentEvent\n\t| FieldUpdatedSegmentEvent\n\t| FieldSettingsOpenedSegmentEvent\n\t| CustomTypeCreatedSegmentEvent\n\t| CustomTypeSliceZoneUpdatedSegmentEvent\n\t| CustomTypeOpenAddFromTemplatesEvent\n\t| CustomTypeSavedSegmentEvent\n\t| SliceCreatedSegmentEvent\n\t| LegacySliceConvertedSegmentEvent\n\t| ScreenshotTakenSegmentEvent\n\t| ChangesPushedSegmentEvent\n\t| ChangesGroupPushedSegmentEvent\n\t| ChangesLimitReachSegmentEvent\n\t| EditorWidgetUsedSegmentEvent\n\t| OpenPageSnippetSegmentEvent\n\t| CopyPageSnippetSegmentEvent\n\t| SwitchEnvironmentSegmentEvent\n\t| DevCollabJoinBetaClicked\n\t| DevCollabSetUpWorkflowOpened\n\t| DevCollabWorkflowStubDisplayed\n\t| SliceMachineStart\n\t| SliceLibraryBetaModalOpened\n\t| SliceLibraryBetaCodeOpened\n\t| SliceMachineSharedOnboardingStepOpened\n\t| SliceMachineSharedOnboardingStepCompleted\n\t| SliceMachineSharedOnboardingCompleted\n\t| SliceMachineSharedOnboardingTutorial\n\t| SliceMachinePostPushEmptyStateCtaClicked\n\t| SliceMachinePostPushToastCtaClicked\n\t| SliceMachineExperimentExposure\n\t| SliceGenerationFeedback;\n"],"names":[],"mappings":";;AAOO,MAAM,mBAAmB;AAAA,EAC/B,oB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ding:step-completed";
|
42
42
|
readonly sharedOnboarding_completed: "shared-onboarding:completed";
|
43
43
|
readonly sharedOnboarding_tutorial: "shared-onboarding:follow-tutorial";
|
44
|
+
readonly sliceGenerationFeedback: "slice-generation-feedback";
|
44
45
|
};
|
45
46
|
type SegmentEventTypes = (typeof SegmentEventType)[keyof typeof SegmentEventType];
|
46
47
|
export declare const HumanSegmentEventType: {
|
@@ -82,6 +83,7 @@ export declare const HumanSegmentEventType: {
|
|
82
83
|
readonly "shared-onboarding:step-opened": "Prismic Onboarding Guide Step Open";
|
83
84
|
readonly "shared-onboarding:completed": "Prismic Onboarding Guide Completed";
|
84
85
|
readonly "shared-onboarding:follow-tutorial": "Prismic Onboarding Guide Follow Tutorial";
|
86
|
+
readonly "slice-generation-feedback": "Slice Generation Feedback";
|
85
87
|
};
|
86
88
|
export type HumanSegmentEventTypes = (typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];
|
87
89
|
type SegmentEvent<TType extends SegmentEventTypes, TProperties extends Record<string, unknown> | void = void> = TProperties extends void ? {
|
@@ -185,6 +187,7 @@ type SliceCreatedSegmentEvent = SegmentEvent<typeof SegmentEventType.slice_creat
|
|
185
187
|
location: "custom_type" | "page_type" | "slices";
|
186
188
|
} & ({
|
187
189
|
mode: "ai";
|
190
|
+
langSmithUrl?: string;
|
188
191
|
} | {
|
189
192
|
mode: "manual";
|
190
193
|
} | {
|
@@ -264,4 +267,11 @@ type SliceMachineExperimentExposure = SegmentEvent<typeof SegmentEventType.exper
|
|
264
267
|
flag_key: string;
|
265
268
|
variant: string;
|
266
269
|
}>;
|
267
|
-
|
270
|
+
type SliceGenerationFeedback = SegmentEvent<typeof SegmentEventType.sliceGenerationFeedback, {
|
271
|
+
type: "model";
|
272
|
+
sliceId: string;
|
273
|
+
variationId: string;
|
274
|
+
feedback: "up" | "down";
|
275
|
+
langSmithUrl?: string;
|
276
|
+
}>;
|
277
|
+
export type SegmentEvents = CommandInitStartSegmentEvent | CommandInitIdentifySegmentEvent | CommandInitEndSegmentEvent | ReviewSegmentEvent | SliceSimulatorOpenSegmentEvent | SliceSimulatorIsNotRunningSegmentEvent | PageViewSegmentEvent | OpenVideoTutorialsSegmentEvent | FieldAddedSegmentEvent | FieldUpdatedSegmentEvent | FieldSettingsOpenedSegmentEvent | CustomTypeCreatedSegmentEvent | CustomTypeSliceZoneUpdatedSegmentEvent | CustomTypeOpenAddFromTemplatesEvent | CustomTypeSavedSegmentEvent | SliceCreatedSegmentEvent | LegacySliceConvertedSegmentEvent | ScreenshotTakenSegmentEvent | ChangesPushedSegmentEvent | ChangesGroupPushedSegmentEvent | ChangesLimitReachSegmentEvent | EditorWidgetUsedSegmentEvent | OpenPageSnippetSegmentEvent | CopyPageSnippetSegmentEvent | SwitchEnvironmentSegmentEvent | DevCollabJoinBetaClicked | DevCollabSetUpWorkflowOpened | DevCollabWorkflowStubDisplayed | SliceMachineStart | SliceLibraryBetaModalOpened | SliceLibraryBetaCodeOpened | SliceMachineSharedOnboardingStepOpened | SliceMachineSharedOnboardingStepCompleted | SliceMachineSharedOnboardingCompleted | SliceMachineSharedOnboardingTutorial | SliceMachinePostPushEmptyStateCtaClicked | SliceMachinePostPushToastCtaClicked | SliceMachineExperimentExposure | SliceGenerationFeedback;
|
@@ -36,7 +36,8 @@ const SegmentEventType = {
|
|
36
36
|
sharedOnboarding_step_opened: "shared-onboarding:step-opened",
|
37
37
|
sharedOnboarding_step_completed: "shared-onboarding:step-completed",
|
38
38
|
sharedOnboarding_completed: "shared-onboarding:completed",
|
39
|
-
sharedOnboarding_tutorial: "shared-onboarding:follow-tutorial"
|
39
|
+
sharedOnboarding_tutorial: "shared-onboarding:follow-tutorial",
|
40
|
+
sliceGenerationFeedback: "slice-generation-feedback"
|
40
41
|
};
|
41
42
|
const HumanSegmentEventType = {
|
42
43
|
[SegmentEventType.command_init_start]: "SliceMachine Init Start",
|
@@ -76,7 +77,8 @@ const HumanSegmentEventType = {
|
|
76
77
|
[SegmentEventType.sharedOnboarding_step_completed]: "Prismic Onboarding Guide Step Completed",
|
77
78
|
[SegmentEventType.sharedOnboarding_step_opened]: "Prismic Onboarding Guide Step Open",
|
78
79
|
[SegmentEventType.sharedOnboarding_completed]: "Prismic Onboarding Guide Completed",
|
79
|
-
[SegmentEventType.sharedOnboarding_tutorial]: "Prismic Onboarding Guide Follow Tutorial"
|
80
|
+
[SegmentEventType.sharedOnboarding_tutorial]: "Prismic Onboarding Guide Follow Tutorial",
|
81
|
+
[SegmentEventType.sliceGenerationFeedback]: "Slice Generation Feedback"
|
80
82
|
};
|
81
83
|
export {
|
82
84
|
HumanSegmentEventType,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../src/managers/telemetry/types.ts"],"sourcesContent":["import { FieldType } from \"@prismicio/types-internal/lib/customtypes/widgets\";\n\nimport { CustomTypeFormat } from \"../customTypes/types\";\nimport type { PushChangesLimitType } from \"../prismicRepository/types\";\n\nexport type { Variant } from \"@amplitude/experiment-node-server\";\n\nexport const SegmentEventType = {\n\tcommand_init_start: \"command:init:start\",\n\tcommand_init_identify: \"command:init:identify\",\n\tcommand_init_end: \"command:init:end\",\n\treview: \"review\",\n\tsliceSimulator_open: \"slice-simulator:open\",\n\tsliceSimulator_isNotRunning: \"slice-simulator:is-not-running\",\n\tpageView: \"page-view\",\n\topenVideoTutorials: \"open-video-tutorials\",\n\tfield_added: \"field:added\",\n\tfield_updated: \"field:updated\",\n\tfield_settingsOpened: \"field:settings-opened\",\n\tcustomType_created: \"custom-type:created\",\n\tcustomType_sliceZoneUpdated: \"custom-type:slice-zone-updated\",\n\tcustomType_openAddFromTemplates: \"custom-type:open-add-from-templates\",\n\tcustomType_saved: \"custom-type:saved\",\n\tslice_created: \"slice:created\",\n\tlegacySlice_converted: \"legacy-slice:converted\",\n\tscreenshotTaken: \"screenshot-taken\",\n\tchanges_pushed: \"changes:pushed\",\n\tchanges_groupPushed: \"changes:group-pushed\",\n\tchanges_limitReach: \"changes:limit-reach\",\n\teditor_widgetUsed: \"editor:widget-used\",\n\topen_page_snippet: \"page-type:open-snippet\",\n\tcopy_page_snippet: \"page-type:copy-snippet\",\n\tswitch_environment: \"environment:switch\",\n\tdevCollab_joinBetaClicked: \"dev-collab:join-beta-clicked\",\n\tdevCollab_setUpWorkflowOpened: \"dev-collab:set-up-workflow-opened\",\n\tdevCollab_workflowStubDisplayed: \"dev-collab:workflow-stub-displayed\",\n\tsliceMachine_start: \"slice-machine:start\",\n\tsliceLibrary_beta_modalOpened: \"slice-library:beta:modal-opened\",\n\tsliceLibrary_beta_codeOpened: \"slice-library:beta:code-opened\",\n\tpostPush_emptyStateCtaClicked: \"post-push:empty-state-cta-clicked\",\n\tpostPush_toastCtaClicked: \"post-push:toast-cta-clicked\",\n\texperiment_exposure: \"experiment:exposure\",\n\tsharedOnboarding_step_opened: \"shared-onboarding:step-opened\",\n\tsharedOnboarding_step_completed: \"shared-onboarding:step-completed\",\n\tsharedOnboarding_completed: \"shared-onboarding:completed\",\n\tsharedOnboarding_tutorial: \"shared-onboarding:follow-tutorial\",\n} as const;\ntype SegmentEventTypes =\n\t(typeof SegmentEventType)[keyof typeof SegmentEventType];\n\nexport const HumanSegmentEventType = {\n\t[SegmentEventType.command_init_start]: \"SliceMachine Init Start\",\n\t[SegmentEventType.command_init_identify]: \"SliceMachine Init Identify\",\n\t[SegmentEventType.command_init_end]: \"SliceMachine Init End\",\n\t[SegmentEventType.review]: \"SliceMachine Review\",\n\t[SegmentEventType.sliceSimulator_open]: \"SliceMachine Slice Simulator Open\",\n\t[SegmentEventType.sliceSimulator_isNotRunning]:\n\t\t\"SliceMachine Slice Simulator is not running\",\n\t[SegmentEventType.pageView]: \"SliceMachine Page View\",\n\t[SegmentEventType.openVideoTutorials]: \"SliceMachine Open Video Tutorials\",\n\t[SegmentEventType.field_added]: \"SliceMachine Field Added\",\n\t[SegmentEventType.field_updated]: \"SliceMachine Field Updated\",\n\t[SegmentEventType.field_settingsOpened]: \"SliceMachine Field Settings Opened\",\n\t[SegmentEventType.customType_created]: \"SliceMachine Custom Type Created\",\n\t[SegmentEventType.customType_sliceZoneUpdated]:\n\t\t\"SliceMachine Slicezone Updated\",\n\t[SegmentEventType.customType_openAddFromTemplates]:\n\t\t\"SliceMachine Open Add from templates\",\n\t[SegmentEventType.customType_saved]: \"SliceMachine Custom Type Saved\",\n\t[SegmentEventType.slice_created]: \"SliceMachine Slice Created\",\n\t[SegmentEventType.legacySlice_converted]:\n\t\t\"SliceMachine Legacy Slice Converted\",\n\t[SegmentEventType.screenshotTaken]: \"SliceMachine Screenshot Taken\",\n\t[SegmentEventType.changes_pushed]: \"SliceMachine Changes Pushed\",\n\t[SegmentEventType.changes_groupPushed]: \"SliceMachine Group Field Pushed\",\n\t[SegmentEventType.changes_limitReach]: \"SliceMachine Changes Limit Reach\",\n\t[SegmentEventType.editor_widgetUsed]: \"SliceMachine Editor Widget Used\",\n\t[SegmentEventType.open_page_snippet]:\n\t\t\"SliceMachine Opens Page Type Snippet Dialog\",\n\t[SegmentEventType.copy_page_snippet]:\n\t\t\"Slice Machine page code snippet copied\",\n\t[SegmentEventType.switch_environment]: \"SliceMachine environment switch\",\n\t[SegmentEventType.devCollab_joinBetaClicked]:\n\t\t\"SliceMachine Dev Collab Join Beta Clicked\",\n\t[SegmentEventType.devCollab_setUpWorkflowOpened]:\n\t\t\"SliceMachine Dev Collab Set Up Workflow Opened\",\n\t[SegmentEventType.devCollab_workflowStubDisplayed]:\n\t\t\"SliceMachine Dev Collab Workflow Stub Displayed\",\n\t[SegmentEventType.sliceMachine_start]: \"SliceMachine Start\",\n\t[SegmentEventType.sliceLibrary_beta_modalOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA modal displayed\",\n\t[SegmentEventType.sliceLibrary_beta_codeOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA example code opened\",\n\t[SegmentEventType.postPush_emptyStateCtaClicked]:\n\t\t\"SliceMachine Post Push Empty State CTA Clicked\",\n\t[SegmentEventType.postPush_toastCtaClicked]:\n\t\t\"SliceMachine Post Push Toast CTA Clicked\",\n\t[SegmentEventType.experiment_exposure]: \"$exposure\",\n\t[SegmentEventType.sharedOnboarding_step_completed]:\n\t\t\"Prismic Onboarding Guide Step Completed\",\n\t[SegmentEventType.sharedOnboarding_step_opened]:\n\t\t\"Prismic Onboarding Guide Step Open\",\n\t[SegmentEventType.sharedOnboarding_completed]:\n\t\t\"Prismic Onboarding Guide Completed\",\n\t[SegmentEventType.sharedOnboarding_tutorial]:\n\t\t\"Prismic Onboarding Guide Follow Tutorial\",\n} as const;\n\nexport type HumanSegmentEventTypes =\n\t(typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];\n\ntype SegmentEvent<\n\tTType extends SegmentEventTypes,\n\tTProperties extends Record<string, unknown> | void = void,\n> = TProperties extends void\n\t? {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t }\n\t: {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t } & TProperties;\n\ntype CommandInitStartSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_start\n>;\n\n// This event feels off, we have a dedicated `identify` method...\ntype CommandInitIdentifySegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_identify\n>;\n\ntype CommandInitEndSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_end,\n\t{ framework: string; success: boolean; error?: string }\n>;\n\ntype ReviewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.review,\n\t{\n\t\trating: number;\n\t\tcomment: string;\n\t\ttype: \"onboarding\";\n\t}\n>;\n\ntype SliceSimulatorOpenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_open\n>;\n\ntype SliceSimulatorIsNotRunningSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_isNotRunning\n>;\n\ntype PageViewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.pageView,\n\t{\n\t\turl: string;\n\t\tpath: string;\n\t\tsearch: string;\n\t\ttitle: string;\n\t\treferrer: string;\n\t\tadapter: string;\n\t\t/*\n\t\t * We are tracking outer sizes instead of inner sizes as with the latter, we\n\t\t * can't differentiate between users with a high-density screen and those\n\t\t * zooming in/out with ⌘ + / ⌘ -. Indeed, when users zoom in/out, some\n\t\t * browsers (like Google Chrome) will update `window.devicePixelRatio` while\n\t\t * others (like Safari) will keep it unchanged so that it always reflects\n\t\t * the ratio of physical pixels to CSS pixels.\n\t\t */\n\t\touterWidth: number;\n\t\touterHeight: number;\n\t\tscreenWidth: number;\n\t\tscreenHeight: number;\n\t}\n>;\n\ntype OpenPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.open_page_snippet,\n\t{ framework: string }\n>;\n\ntype CopyPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.copy_page_snippet,\n\t{ framework: string }\n>;\n\ntype SwitchEnvironmentSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.switch_environment,\n\t{ domain: string }\n>;\n\ntype OpenVideoTutorialsSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.openVideoTutorials,\n\t{ video: string }\n>;\n\ntype FieldAddedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_added,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_updated,\n\t{\n\t\tpreviousId: string;\n\t\tid: string;\n\t\tidUpdated: boolean;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldSettingsOpenedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_settingsOpened,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t}\n>;\n\ntype CustomTypeCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t\torigin: \"onboarding\" | \"table\";\n\t}\n>;\n\ntype CustomTypeSliceZoneUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_sliceZoneUpdated,\n\t{ customTypeId: string }\n>;\n\ntype CustomTypeOpenAddFromTemplatesEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_openAddFromTemplates,\n\t{ customTypeId: string; customTypeFormat: CustomTypeFormat }\n>;\n\ntype CustomTypeSavedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_saved,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t}\n>;\n\ntype SliceCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.slice_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tlibrary: string;\n\t\tlocation: \"custom_type\" | \"page_type\" | \"slices\";\n\t} & (\n\t\t| { mode: \"ai\" }\n\t\t| { mode: \"manual\" }\n\t\t| { mode: \"template\"; sliceTemplate: string }\n\t)\n>;\n\ntype LegacySliceConvertedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.legacySlice_converted,\n\t{\n\t\tid: string;\n\t\tvariation: string;\n\t\tlibrary: string;\n\t\tconversionType:\n\t\t\t| \"as_new_slice\"\n\t\t\t| \"as_new_variation\"\n\t\t\t| \"merge_with_identical\";\n\t}\n>;\n\ntype ScreenshotTakenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.screenshotTaken,\n\t{\n\t\ttype: \"custom\";\n\t\tmethod: \"upload\" | \"dragAndDrop\";\n\t}\n>;\n\ntype ChangesPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_pushed,\n\t{\n\t\tcustomTypesCreated: number;\n\t\tcustomTypesModified: number;\n\t\tcustomTypesDeleted: number;\n\t\tslicesCreated: number;\n\t\tslicesModified: number;\n\t\tslicesDeleted: number;\n\t\tmissingScreenshots: number;\n\t\ttotal: number;\n\t\tduration: number;\n\t\thasDeletedDocuments: boolean;\n\t}\n>;\n\ntype ChangesGroupPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_groupPushed,\n\t{\n\t\tisInStaticZone: boolean;\n\t\tisInSlice: boolean;\n\t} & {\n\t\t[key in FieldType]?: number;\n\t}\n>;\n\ntype ChangesLimitReachSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_limitReach,\n\t{ limitType: PushChangesLimitType }\n>;\n\ntype EditorWidgetUsedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.editor_widgetUsed,\n\t{ sliceId: string }\n>;\n\ntype DevCollabJoinBetaClicked = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_joinBetaClicked\n>;\n\ntype DevCollabSetUpWorkflowOpened = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_setUpWorkflowOpened\n>;\n\ntype DevCollabWorkflowStubDisplayed = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_workflowStubDisplayed\n>;\n\ntype SliceMachineStart = SegmentEvent<\n\ttypeof SegmentEventType.sliceMachine_start,\n\t{\n\t\tadapter?: string;\n\t\tadapterVersion?: string;\n\t\tgitProvider?: string;\n\t\tisAdapterUpdateAvailable?: boolean;\n\t\tisLoggedIn?: boolean;\n\t\tisSliceMachineUpdateAvailable?: boolean;\n\t\tisTypeScriptProject?: boolean;\n\t\tnodeVersion?: string;\n\t\tnumberOfCustomTypes?: number;\n\t\tnumberOfSlices?: number;\n\t\tosPlatform?: string;\n\t\tpackageManager?: string;\n\t\tprojectPort?: string;\n\t\tsliceMachineVersion?: string;\n\t\tversionControlSystem?: string;\n\t}\n>;\n\ntype SliceLibraryBetaModalOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_modalOpened\n>;\n\ntype SliceLibraryBetaCodeOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_codeOpened\n>;\n\ntype OnboardingCommonPayload = { stepId: string; stepTitle: string };\ntype SharedOnboardingProperties<T = Record<string, string>> = T & {\n\tsource: \"SliceMachine\";\n};\n\ntype SliceMachineSharedOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_opened,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_completed,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_completed,\n\tSharedOnboardingProperties\n>;\ntype SliceMachineSharedOnboardingTutorial = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_tutorial,\n\tSharedOnboardingProperties\n>;\ntype SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_emptyStateCtaClicked\n>;\n\ntype SliceMachinePostPushToastCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_toastCtaClicked\n>;\n\ntype SliceMachineExperimentExposure = SegmentEvent<\n\ttypeof SegmentEventType.experiment_exposure,\n\t{\n\t\tflag_key: string;\n\t\tvariant: string;\n\t}\n>;\n\nexport type SegmentEvents =\n\t| CommandInitStartSegmentEvent\n\t| CommandInitIdentifySegmentEvent\n\t| CommandInitEndSegmentEvent\n\t| ReviewSegmentEvent\n\t| SliceSimulatorOpenSegmentEvent\n\t| SliceSimulatorIsNotRunningSegmentEvent\n\t| PageViewSegmentEvent\n\t| OpenVideoTutorialsSegmentEvent\n\t| FieldAddedSegmentEvent\n\t| FieldUpdatedSegmentEvent\n\t| FieldSettingsOpenedSegmentEvent\n\t| CustomTypeCreatedSegmentEvent\n\t| CustomTypeSliceZoneUpdatedSegmentEvent\n\t| CustomTypeOpenAddFromTemplatesEvent\n\t| CustomTypeSavedSegmentEvent\n\t| SliceCreatedSegmentEvent\n\t| LegacySliceConvertedSegmentEvent\n\t| ScreenshotTakenSegmentEvent\n\t| ChangesPushedSegmentEvent\n\t| ChangesGroupPushedSegmentEvent\n\t| ChangesLimitReachSegmentEvent\n\t| EditorWidgetUsedSegmentEvent\n\t| OpenPageSnippetSegmentEvent\n\t| CopyPageSnippetSegmentEvent\n\t| SwitchEnvironmentSegmentEvent\n\t| DevCollabJoinBetaClicked\n\t| DevCollabSetUpWorkflowOpened\n\t| DevCollabWorkflowStubDisplayed\n\t| SliceMachineStart\n\t| SliceLibraryBetaModalOpened\n\t| SliceLibraryBetaCodeOpened\n\t| SliceMachineSharedOnboardingStepOpened\n\t| SliceMachineSharedOnboardingStepCompleted\n\t| SliceMachineSharedOnboardingCompleted\n\t| SliceMachineSharedOnboardingTutorial\n\t| SliceMachinePostPushEmptyStateCtaClicked\n\t| SliceMachinePostPushToastCtaClicked\n\t| SliceMachineExperimentExposure;\n"],"names":[],"mappings":"AAOO,MAAM,mBAAmB;AAAA,EAC/B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA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CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,iBAAiB,GAAG;AAAA,EACtC,CAAC,iBAAiB,iBAAiB,GAClC;AAAA,EACD,CAAC,iBAAiB,iBAAiB,GAClC;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,wBAAwB,GACzC;AAAA,EACD,CAAC,iBAAiB,mBAAmB,GAAG;AAAA,EACxC,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,0BAA0B,GAC3C;AAAA,EACD,CAAC,iBAAiB,yBAAyB,GAC1C;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/managers/telemetry/types.ts"],"sourcesContent":["import { FieldType } from \"@prismicio/types-internal/lib/customtypes/widgets\";\n\nimport { CustomTypeFormat } from \"../customTypes/types\";\nimport type { PushChangesLimitType } from \"../prismicRepository/types\";\n\nexport type { Variant } from \"@amplitude/experiment-node-server\";\n\nexport const SegmentEventType = {\n\tcommand_init_start: \"command:init:start\",\n\tcommand_init_identify: \"command:init:identify\",\n\tcommand_init_end: \"command:init:end\",\n\treview: \"review\",\n\tsliceSimulator_open: \"slice-simulator:open\",\n\tsliceSimulator_isNotRunning: \"slice-simulator:is-not-running\",\n\tpageView: \"page-view\",\n\topenVideoTutorials: \"open-video-tutorials\",\n\tfield_added: \"field:added\",\n\tfield_updated: \"field:updated\",\n\tfield_settingsOpened: \"field:settings-opened\",\n\tcustomType_created: \"custom-type:created\",\n\tcustomType_sliceZoneUpdated: \"custom-type:slice-zone-updated\",\n\tcustomType_openAddFromTemplates: \"custom-type:open-add-from-templates\",\n\tcustomType_saved: \"custom-type:saved\",\n\tslice_created: \"slice:created\",\n\tlegacySlice_converted: \"legacy-slice:converted\",\n\tscreenshotTaken: \"screenshot-taken\",\n\tchanges_pushed: \"changes:pushed\",\n\tchanges_groupPushed: \"changes:group-pushed\",\n\tchanges_limitReach: \"changes:limit-reach\",\n\teditor_widgetUsed: \"editor:widget-used\",\n\topen_page_snippet: \"page-type:open-snippet\",\n\tcopy_page_snippet: \"page-type:copy-snippet\",\n\tswitch_environment: \"environment:switch\",\n\tdevCollab_joinBetaClicked: \"dev-collab:join-beta-clicked\",\n\tdevCollab_setUpWorkflowOpened: \"dev-collab:set-up-workflow-opened\",\n\tdevCollab_workflowStubDisplayed: \"dev-collab:workflow-stub-displayed\",\n\tsliceMachine_start: \"slice-machine:start\",\n\tsliceLibrary_beta_modalOpened: \"slice-library:beta:modal-opened\",\n\tsliceLibrary_beta_codeOpened: \"slice-library:beta:code-opened\",\n\tpostPush_emptyStateCtaClicked: \"post-push:empty-state-cta-clicked\",\n\tpostPush_toastCtaClicked: \"post-push:toast-cta-clicked\",\n\texperiment_exposure: \"experiment:exposure\",\n\tsharedOnboarding_step_opened: \"shared-onboarding:step-opened\",\n\tsharedOnboarding_step_completed: \"shared-onboarding:step-completed\",\n\tsharedOnboarding_completed: \"shared-onboarding:completed\",\n\tsharedOnboarding_tutorial: \"shared-onboarding:follow-tutorial\",\n\tsliceGenerationFeedback: \"slice-generation-feedback\",\n} as const;\ntype SegmentEventTypes =\n\t(typeof SegmentEventType)[keyof typeof SegmentEventType];\n\nexport const HumanSegmentEventType = {\n\t[SegmentEventType.command_init_start]: \"SliceMachine Init Start\",\n\t[SegmentEventType.command_init_identify]: \"SliceMachine Init Identify\",\n\t[SegmentEventType.command_init_end]: \"SliceMachine Init End\",\n\t[SegmentEventType.review]: \"SliceMachine Review\",\n\t[SegmentEventType.sliceSimulator_open]: \"SliceMachine Slice Simulator Open\",\n\t[SegmentEventType.sliceSimulator_isNotRunning]:\n\t\t\"SliceMachine Slice Simulator is not running\",\n\t[SegmentEventType.pageView]: \"SliceMachine Page View\",\n\t[SegmentEventType.openVideoTutorials]: \"SliceMachine Open Video Tutorials\",\n\t[SegmentEventType.field_added]: \"SliceMachine Field Added\",\n\t[SegmentEventType.field_updated]: \"SliceMachine Field Updated\",\n\t[SegmentEventType.field_settingsOpened]: \"SliceMachine Field Settings Opened\",\n\t[SegmentEventType.customType_created]: \"SliceMachine Custom Type Created\",\n\t[SegmentEventType.customType_sliceZoneUpdated]:\n\t\t\"SliceMachine Slicezone Updated\",\n\t[SegmentEventType.customType_openAddFromTemplates]:\n\t\t\"SliceMachine Open Add from templates\",\n\t[SegmentEventType.customType_saved]: \"SliceMachine Custom Type Saved\",\n\t[SegmentEventType.slice_created]: \"SliceMachine Slice Created\",\n\t[SegmentEventType.legacySlice_converted]:\n\t\t\"SliceMachine Legacy Slice Converted\",\n\t[SegmentEventType.screenshotTaken]: \"SliceMachine Screenshot Taken\",\n\t[SegmentEventType.changes_pushed]: \"SliceMachine Changes Pushed\",\n\t[SegmentEventType.changes_groupPushed]: \"SliceMachine Group Field Pushed\",\n\t[SegmentEventType.changes_limitReach]: \"SliceMachine Changes Limit Reach\",\n\t[SegmentEventType.editor_widgetUsed]: \"SliceMachine Editor Widget Used\",\n\t[SegmentEventType.open_page_snippet]:\n\t\t\"SliceMachine Opens Page Type Snippet Dialog\",\n\t[SegmentEventType.copy_page_snippet]:\n\t\t\"Slice Machine page code snippet copied\",\n\t[SegmentEventType.switch_environment]: \"SliceMachine environment switch\",\n\t[SegmentEventType.devCollab_joinBetaClicked]:\n\t\t\"SliceMachine Dev Collab Join Beta Clicked\",\n\t[SegmentEventType.devCollab_setUpWorkflowOpened]:\n\t\t\"SliceMachine Dev Collab Set Up Workflow Opened\",\n\t[SegmentEventType.devCollab_workflowStubDisplayed]:\n\t\t\"SliceMachine Dev Collab Workflow Stub Displayed\",\n\t[SegmentEventType.sliceMachine_start]: \"SliceMachine Start\",\n\t[SegmentEventType.sliceLibrary_beta_modalOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA modal displayed\",\n\t[SegmentEventType.sliceLibrary_beta_codeOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA example code opened\",\n\t[SegmentEventType.postPush_emptyStateCtaClicked]:\n\t\t\"SliceMachine Post Push Empty State CTA Clicked\",\n\t[SegmentEventType.postPush_toastCtaClicked]:\n\t\t\"SliceMachine Post Push Toast CTA Clicked\",\n\t[SegmentEventType.experiment_exposure]: \"$exposure\",\n\t[SegmentEventType.sharedOnboarding_step_completed]:\n\t\t\"Prismic Onboarding Guide Step Completed\",\n\t[SegmentEventType.sharedOnboarding_step_opened]:\n\t\t\"Prismic Onboarding Guide Step Open\",\n\t[SegmentEventType.sharedOnboarding_completed]:\n\t\t\"Prismic Onboarding Guide Completed\",\n\t[SegmentEventType.sharedOnboarding_tutorial]:\n\t\t\"Prismic Onboarding Guide Follow Tutorial\",\n\t[SegmentEventType.sliceGenerationFeedback]: \"Slice Generation Feedback\",\n} as const;\n\nexport type HumanSegmentEventTypes =\n\t(typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];\n\ntype SegmentEvent<\n\tTType extends SegmentEventTypes,\n\tTProperties extends Record<string, unknown> | void = void,\n> = TProperties extends void\n\t? {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t }\n\t: {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t } & TProperties;\n\ntype CommandInitStartSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_start\n>;\n\n// This event feels off, we have a dedicated `identify` method...\ntype CommandInitIdentifySegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_identify\n>;\n\ntype CommandInitEndSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_end,\n\t{ framework: string; success: boolean; error?: string }\n>;\n\ntype ReviewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.review,\n\t{\n\t\trating: number;\n\t\tcomment: string;\n\t\ttype: \"onboarding\";\n\t}\n>;\n\ntype SliceSimulatorOpenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_open\n>;\n\ntype SliceSimulatorIsNotRunningSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_isNotRunning\n>;\n\ntype PageViewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.pageView,\n\t{\n\t\turl: string;\n\t\tpath: string;\n\t\tsearch: string;\n\t\ttitle: string;\n\t\treferrer: string;\n\t\tadapter: string;\n\t\t/*\n\t\t * We are tracking outer sizes instead of inner sizes as with the latter, we\n\t\t * can't differentiate between users with a high-density screen and those\n\t\t * zooming in/out with ⌘ + / ⌘ -. Indeed, when users zoom in/out, some\n\t\t * browsers (like Google Chrome) will update `window.devicePixelRatio` while\n\t\t * others (like Safari) will keep it unchanged so that it always reflects\n\t\t * the ratio of physical pixels to CSS pixels.\n\t\t */\n\t\touterWidth: number;\n\t\touterHeight: number;\n\t\tscreenWidth: number;\n\t\tscreenHeight: number;\n\t}\n>;\n\ntype OpenPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.open_page_snippet,\n\t{ framework: string }\n>;\n\ntype CopyPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.copy_page_snippet,\n\t{ framework: string }\n>;\n\ntype SwitchEnvironmentSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.switch_environment,\n\t{ domain: string }\n>;\n\ntype OpenVideoTutorialsSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.openVideoTutorials,\n\t{ video: string }\n>;\n\ntype FieldAddedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_added,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_updated,\n\t{\n\t\tpreviousId: string;\n\t\tid: string;\n\t\tidUpdated: boolean;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t\trepeat?: boolean;\n\t\tvariants?: string[];\n\t}\n>;\n\ntype FieldSettingsOpenedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_settingsOpened,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t}\n>;\n\ntype CustomTypeCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t\torigin: \"onboarding\" | \"table\";\n\t}\n>;\n\ntype CustomTypeSliceZoneUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_sliceZoneUpdated,\n\t{ customTypeId: string }\n>;\n\ntype CustomTypeOpenAddFromTemplatesEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_openAddFromTemplates,\n\t{ customTypeId: string; customTypeFormat: CustomTypeFormat }\n>;\n\ntype CustomTypeSavedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_saved,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t}\n>;\n\ntype SliceCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.slice_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tlibrary: string;\n\t\tlocation: \"custom_type\" | \"page_type\" | \"slices\";\n\t} & (\n\t\t| { mode: \"ai\"; langSmithUrl?: string }\n\t\t| { mode: \"manual\" }\n\t\t| { mode: \"template\"; sliceTemplate: string }\n\t)\n>;\n\ntype LegacySliceConvertedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.legacySlice_converted,\n\t{\n\t\tid: string;\n\t\tvariation: string;\n\t\tlibrary: string;\n\t\tconversionType:\n\t\t\t| \"as_new_slice\"\n\t\t\t| \"as_new_variation\"\n\t\t\t| \"merge_with_identical\";\n\t}\n>;\n\ntype ScreenshotTakenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.screenshotTaken,\n\t{\n\t\ttype: \"custom\";\n\t\tmethod: \"upload\" | \"dragAndDrop\";\n\t}\n>;\n\ntype ChangesPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_pushed,\n\t{\n\t\tcustomTypesCreated: number;\n\t\tcustomTypesModified: number;\n\t\tcustomTypesDeleted: number;\n\t\tslicesCreated: number;\n\t\tslicesModified: number;\n\t\tslicesDeleted: number;\n\t\tmissingScreenshots: number;\n\t\ttotal: number;\n\t\tduration: number;\n\t\thasDeletedDocuments: boolean;\n\t}\n>;\n\ntype ChangesGroupPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_groupPushed,\n\t{\n\t\tisInStaticZone: boolean;\n\t\tisInSlice: boolean;\n\t} & {\n\t\t[key in FieldType]?: number;\n\t}\n>;\n\ntype ChangesLimitReachSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_limitReach,\n\t{ limitType: PushChangesLimitType }\n>;\n\ntype EditorWidgetUsedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.editor_widgetUsed,\n\t{ sliceId: string }\n>;\n\ntype DevCollabJoinBetaClicked = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_joinBetaClicked\n>;\n\ntype DevCollabSetUpWorkflowOpened = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_setUpWorkflowOpened\n>;\n\ntype DevCollabWorkflowStubDisplayed = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_workflowStubDisplayed\n>;\n\ntype SliceMachineStart = SegmentEvent<\n\ttypeof SegmentEventType.sliceMachine_start,\n\t{\n\t\tadapter?: string;\n\t\tadapterVersion?: string;\n\t\tgitProvider?: string;\n\t\tisAdapterUpdateAvailable?: boolean;\n\t\tisLoggedIn?: boolean;\n\t\tisSliceMachineUpdateAvailable?: boolean;\n\t\tisTypeScriptProject?: boolean;\n\t\tnodeVersion?: string;\n\t\tnumberOfCustomTypes?: number;\n\t\tnumberOfSlices?: number;\n\t\tosPlatform?: string;\n\t\tpackageManager?: string;\n\t\tprojectPort?: string;\n\t\tsliceMachineVersion?: string;\n\t\tversionControlSystem?: string;\n\t}\n>;\n\ntype SliceLibraryBetaModalOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_modalOpened\n>;\n\ntype SliceLibraryBetaCodeOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_codeOpened\n>;\n\ntype OnboardingCommonPayload = { stepId: string; stepTitle: string };\ntype SharedOnboardingProperties<T = Record<string, string>> = T & {\n\tsource: \"SliceMachine\";\n};\n\ntype SliceMachineSharedOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_opened,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_completed,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_completed,\n\tSharedOnboardingProperties\n>;\ntype SliceMachineSharedOnboardingTutorial = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_tutorial,\n\tSharedOnboardingProperties\n>;\ntype SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_emptyStateCtaClicked\n>;\n\ntype SliceMachinePostPushToastCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_toastCtaClicked\n>;\n\ntype SliceMachineExperimentExposure = SegmentEvent<\n\ttypeof SegmentEventType.experiment_exposure,\n\t{\n\t\tflag_key: string;\n\t\tvariant: string;\n\t}\n>;\n\ntype SliceGenerationFeedback = SegmentEvent<\n\ttypeof SegmentEventType.sliceGenerationFeedback,\n\t{\n\t\ttype: \"model\";\n\t\tsliceId: string;\n\t\tvariationId: string;\n\t\tfeedback: \"up\" | \"down\";\n\t\tlangSmithUrl?: string;\n\t}\n>;\n\nexport type SegmentEvents =\n\t| CommandInitStartSegmentEvent\n\t| CommandInitIdentifySegmentEvent\n\t| CommandInitEndSegmentEvent\n\t| ReviewSegmentEvent\n\t| SliceSimulatorOpenSegmentEvent\n\t| SliceSimulatorIsNotRunningSegmentEvent\n\t| PageViewSegmentEvent\n\t| OpenVideoTutorialsSegmentEvent\n\t| FieldAddedSegmentEvent\n\t| FieldUpdatedSegmentEvent\n\t| FieldSettingsOpenedSegmentEvent\n\t| CustomTypeCreatedSegmentEvent\n\t| CustomTypeSliceZoneUpdatedSegmentEvent\n\t| CustomTypeOpenAddFromTemplatesEvent\n\t| CustomTypeSavedSegmentEvent\n\t| SliceCreatedSegmentEvent\n\t| LegacySliceConvertedSegmentEvent\n\t| ScreenshotTakenSegmentEvent\n\t| ChangesPushedSegmentEvent\n\t| ChangesGroupPushedSegmentEvent\n\t| ChangesLimitReachSegmentEvent\n\t| EditorWidgetUsedSegmentEvent\n\t| OpenPageSnippetSegmentEvent\n\t| CopyPageSnippetSegmentEvent\n\t| SwitchEnvironmentSegmentEvent\n\t| DevCollabJoinBetaClicked\n\t| DevCollabSetUpWorkflowOpened\n\t| DevCollabWorkflowStubDisplayed\n\t| SliceMachineStart\n\t| SliceLibraryBetaModalOpened\n\t| SliceLibraryBetaCodeOpened\n\t| SliceMachineSharedOnboardingStepOpened\n\t| SliceMachineSharedOnboardingStepCompleted\n\t| SliceMachineSharedOnboardingCompleted\n\t| SliceMachineSharedOnboardingTutorial\n\t| SliceMachinePostPushEmptyStateCtaClicked\n\t| SliceMachinePostPushToastCtaClicked\n\t| SliceMachineExperimentExposure\n\t| SliceGenerationFeedback;\n"],"names":[],"mappings":"AAOO,MAAM,mBAAmB;AAAA,EAC/B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,+BAA+B;AAAA,EAC/B,iCAAiC;AAAA,EACjC,oBAAoB;AAAA,EACpB,+BAA+B;AAAA,EAC/B,8BAA8B;AAAA,EAC9B,+BAA+B;AAAA,EAC/B,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,8BAA8B;AAAA,EAC9B,iCAAiC;AAAA,EACjC,4BAA4B;AAAA,EAC5B,2BAA2B;AAAA,EAC3B,yBAAyB;;AAKnB,MAAM,wBAAwB;AAAA,EACpC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,qBAAqB,GAAG;AAAA,EAC1C,CAAC,iBAAiB,gBAAgB,GAAG;AAAA,EACrC,CAAC,iBAAiB,MAAM,GAAG;AAAA,EAC3B,CAAC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AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,0BAA0B,GAC3C;AAAA,EACD,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,uBAAuB,GAAG;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@slicemachine/manager",
|
3
|
-
"version": "0.24.11-alpha.
|
3
|
+
"version": "0.24.11-alpha.xru-add-slice-to-slicezone-bottom.1",
|
4
4
|
"description": "Manage all aspects of a Slice Machine project.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -70,7 +70,7 @@
|
|
70
70
|
"@prismicio/mocks": "2.12.0",
|
71
71
|
"@prismicio/types-internal": "3.8.0",
|
72
72
|
"@segment/analytics-node": "^2.1.2",
|
73
|
-
"@slicemachine/plugin-kit": "0.4.73-alpha.
|
73
|
+
"@slicemachine/plugin-kit": "0.4.73-alpha.xru-add-slice-to-slicezone-bottom.1",
|
74
74
|
"cookie": "^1.0.1",
|
75
75
|
"cors": "^2.8.5",
|
76
76
|
"execa": "^7.1.1",
|
@@ -44,6 +44,7 @@ export const SegmentEventType = {
|
|
44
44
|
sharedOnboarding_step_completed: "shared-onboarding:step-completed",
|
45
45
|
sharedOnboarding_completed: "shared-onboarding:completed",
|
46
46
|
sharedOnboarding_tutorial: "shared-onboarding:follow-tutorial",
|
47
|
+
sliceGenerationFeedback: "slice-generation-feedback",
|
47
48
|
} as const;
|
48
49
|
type SegmentEventTypes =
|
49
50
|
(typeof SegmentEventType)[keyof typeof SegmentEventType];
|
@@ -104,6 +105,7 @@ export const HumanSegmentEventType = {
|
|
104
105
|
"Prismic Onboarding Guide Completed",
|
105
106
|
[SegmentEventType.sharedOnboarding_tutorial]:
|
106
107
|
"Prismic Onboarding Guide Follow Tutorial",
|
108
|
+
[SegmentEventType.sliceGenerationFeedback]: "Slice Generation Feedback",
|
107
109
|
} as const;
|
108
110
|
|
109
111
|
export type HumanSegmentEventTypes =
|
@@ -277,7 +279,7 @@ type SliceCreatedSegmentEvent = SegmentEvent<
|
|
277
279
|
library: string;
|
278
280
|
location: "custom_type" | "page_type" | "slices";
|
279
281
|
} & (
|
280
|
-
| { mode: "ai" }
|
282
|
+
| { mode: "ai"; langSmithUrl?: string }
|
281
283
|
| { mode: "manual" }
|
282
284
|
| { mode: "template"; sliceTemplate: string }
|
283
285
|
)
|
@@ -418,6 +420,17 @@ type SliceMachineExperimentExposure = SegmentEvent<
|
|
418
420
|
}
|
419
421
|
>;
|
420
422
|
|
423
|
+
type SliceGenerationFeedback = SegmentEvent<
|
424
|
+
typeof SegmentEventType.sliceGenerationFeedback,
|
425
|
+
{
|
426
|
+
type: "model";
|
427
|
+
sliceId: string;
|
428
|
+
variationId: string;
|
429
|
+
feedback: "up" | "down";
|
430
|
+
langSmithUrl?: string;
|
431
|
+
}
|
432
|
+
>;
|
433
|
+
|
421
434
|
export type SegmentEvents =
|
422
435
|
| CommandInitStartSegmentEvent
|
423
436
|
| CommandInitIdentifySegmentEvent
|
@@ -456,4 +469,5 @@ export type SegmentEvents =
|
|
456
469
|
| SliceMachineSharedOnboardingTutorial
|
457
470
|
| SliceMachinePostPushEmptyStateCtaClicked
|
458
471
|
| SliceMachinePostPushToastCtaClicked
|
459
|
-
| SliceMachineExperimentExposure
|
472
|
+
| SliceMachineExperimentExposure
|
473
|
+
| SliceGenerationFeedback;
|