@uniformdev/mesh-edgehancer-sdk 19.79.1-alpha.13

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.
@@ -0,0 +1,194 @@
1
+ // src/batchUtils.ts
2
+ function convertBatchResultsToEdgehancerResult({
3
+ batch,
4
+ batchFetchIds: { invalidBatchIndices, validIdToOriginalIndexMap },
5
+ batchResults,
6
+ resolveIdFromBatchResultFn,
7
+ knownInvalidErrorMessage = "batch request ID could not be read from the data resource",
8
+ missingBatchResultErrorMessage = () => "batch request did not return a result for the data resource ID"
9
+ }) {
10
+ const results = new Array(batch.length);
11
+ if (!Array.isArray(batchResults)) {
12
+ throw new Error(`batchResults is not an array (got ${typeof batchResults})`);
13
+ }
14
+ for (const batchResult of batchResults) {
15
+ const resultId = resolveIdFromBatchResultFn(batchResult);
16
+ const batchIndex = validIdToOriginalIndexMap.get(resultId);
17
+ if (batchIndex !== void 0) {
18
+ results[batchIndex] = {
19
+ result: batchResult
20
+ };
21
+ }
22
+ }
23
+ for (const batchIndex of invalidBatchIndices) {
24
+ results[batchIndex] = {
25
+ errors: [knownInvalidErrorMessage]
26
+ };
27
+ }
28
+ for (let batchIndex = 0; batchIndex < results.length; batchIndex++) {
29
+ if (results[batchIndex] === void 0) {
30
+ results[batchIndex] = {
31
+ errors: [missingBatchResultErrorMessage(batch[batchIndex])]
32
+ };
33
+ }
34
+ }
35
+ return results;
36
+ }
37
+ function resolveBatchFetchIds(batch, resolveBatchItemIdFn) {
38
+ const result = {
39
+ invalidBatchIndices: /* @__PURE__ */ new Set(),
40
+ validIds: [],
41
+ validIdToOriginalIndexMap: /* @__PURE__ */ new Map()
42
+ };
43
+ batch.forEach((context, batchIndex) => {
44
+ const id = resolveBatchItemIdFn(context);
45
+ if (id === void 0) {
46
+ result.invalidBatchIndices.add(batchIndex);
47
+ return;
48
+ }
49
+ result.validIdToOriginalIndexMap.set(id, batchIndex);
50
+ result.validIds.push(id);
51
+ });
52
+ return result;
53
+ }
54
+
55
+ // src/fetchUtils.ts
56
+ function getDataResourceAsRequest(data) {
57
+ var _a;
58
+ const method = (_a = data.method) != null ? _a : "GET";
59
+ const body = method === "POST" ? data.body : void 0;
60
+ const headers = getDataResourceHeaders(data);
61
+ const url = getDataResourceUrl(data);
62
+ return new Request(url, { method, headers, body });
63
+ }
64
+ function getDataResourceUrl(dataResource) {
65
+ const urlParts = dataResource.url.split("?");
66
+ const queryString = getDataResourceQueryString(dataResource);
67
+ const url = new URL(urlParts[0]).toString();
68
+ return url + (queryString.length > 0 ? `?${queryString}` : "");
69
+ }
70
+ function getDataResourceQueryString({ parameters, url }) {
71
+ const urlParts = url.split("?");
72
+ const searchParams = copyKeyValuePairs(parameters, new URLSearchParams(urlParts[1]));
73
+ return Array.from(searchParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
74
+ }
75
+ function getDataResourceHeaders({ headers }) {
76
+ return copyKeyValuePairs(headers, new Headers());
77
+ }
78
+ function copyKeyValuePairs(source, target) {
79
+ if (Array.isArray(source)) {
80
+ [...source].sort((a, b) => a.key.localeCompare(b.key)).forEach(({ key, value, omitIfEmpty }) => {
81
+ if (value || !omitIfEmpty) {
82
+ target.append(key, value);
83
+ }
84
+ });
85
+ } else if (source) {
86
+ Object.keys(source).sort((a, b) => a.localeCompare(b)).forEach((key) => {
87
+ target.append(key, source[key]);
88
+ });
89
+ }
90
+ return target;
91
+ }
92
+
93
+ // src/preRequest.ts
94
+ import { z as z2 } from "zod";
95
+
96
+ // src/shared.ts
97
+ import { assert } from "tsafe";
98
+ import { z } from "zod";
99
+ var parameterDefinitionSchema = z.object({
100
+ key: z.string(),
101
+ value: z.string(),
102
+ omitIfEmpty: z.boolean().optional()
103
+ });
104
+ var variableDefinitionSchema = z.object({
105
+ displayName: z.string().optional(),
106
+ type: z.string().optional(),
107
+ default: z.string(),
108
+ helpText: z.string().optional(),
109
+ order: z.number().optional(),
110
+ source: z.string().optional()
111
+ });
112
+ var customEdgehancerDefinitionSchema = z.object({
113
+ preRequest: z.string().optional(),
114
+ request: z.string().optional()
115
+ });
116
+ var mergedDataTypeSchema = z.object({
117
+ id: z.string(),
118
+ displayName: z.string(),
119
+ archetype: z.string().optional(),
120
+ allowedOnComponents: z.array(z.string()).optional(),
121
+ badgeIconUrl: z.string().optional(),
122
+ connectorType: z.string(),
123
+ url: z.string(),
124
+ headers: z.array(parameterDefinitionSchema).optional(),
125
+ parameters: z.array(parameterDefinitionSchema).optional(),
126
+ body: z.string().optional(),
127
+ method: z.enum(["GET", "POST", "HEAD"]),
128
+ variables: z.record(variableDefinitionSchema).optional(),
129
+ custom: z.record(z.unknown()).optional(),
130
+ ttl: z.number().optional(),
131
+ purgeKey: z.string().optional(),
132
+ localeMapping: z.record(z.string()).optional(),
133
+ edgehancer: customEdgehancerDefinitionSchema.optional(),
134
+ uiBadgeText: z.string().max(12).optional()
135
+ });
136
+ assert();
137
+ var dataResourceSchema = z.union([
138
+ z.string(),
139
+ z.object({}).catchall(z.unknown()),
140
+ z.number(),
141
+ z.boolean(),
142
+ z.array(z.unknown()),
143
+ z.undefined()
144
+ ]);
145
+
146
+ // src/preRequest.ts
147
+ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
148
+ edgehancer: true,
149
+ allowedOnComponents: true,
150
+ badgeIconUrl: true,
151
+ displayName: true,
152
+ id: true,
153
+ purgeKey: true,
154
+ variables: true
155
+ });
156
+ var preRequestEdgehancerDataResourceResultSchema = z2.strictObject({
157
+ errors: z2.array(z2.string()).optional(),
158
+ warnings: z2.array(z2.string()).optional(),
159
+ dataResource: edgehancerMergedDataTypeSchema
160
+ });
161
+ var preRequestEdgehancerResultSchema = z2.strictObject({
162
+ dataResources: z2.array(preRequestEdgehancerDataResourceResultSchema)
163
+ });
164
+
165
+ // src/request.ts
166
+ import { z as z3 } from "zod";
167
+ var requestEdgehancerDataResourceResolutionResultSchema = z3.strictObject({
168
+ errors: z3.array(z3.string()).optional().describe(
169
+ "Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
170
+ ),
171
+ warnings: z3.array(z3.string()).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
172
+ surrogateKeys: z3.array(z3.string()).optional().describe(
173
+ "Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
174
+ ),
175
+ result: dataResourceSchema.describe("The result of fetching the data resource")
176
+ });
177
+ var requestEdgehancerResultSchema = z3.strictObject({
178
+ results: z3.array(requestEdgehancerDataResourceResolutionResultSchema)
179
+ });
180
+ export {
181
+ convertBatchResultsToEdgehancerResult,
182
+ dataResourceSchema,
183
+ edgehancerMergedDataTypeSchema,
184
+ getDataResourceAsRequest,
185
+ getDataResourceHeaders,
186
+ getDataResourceQueryString,
187
+ getDataResourceUrl,
188
+ mergedDataTypeSchema,
189
+ preRequestEdgehancerDataResourceResultSchema,
190
+ preRequestEdgehancerResultSchema,
191
+ requestEdgehancerDataResourceResolutionResultSchema,
192
+ requestEdgehancerResultSchema,
193
+ resolveBatchFetchIds
194
+ };
package/dist/index.js ADDED
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ convertBatchResultsToEdgehancerResult: () => convertBatchResultsToEdgehancerResult,
24
+ dataResourceSchema: () => dataResourceSchema,
25
+ edgehancerMergedDataTypeSchema: () => edgehancerMergedDataTypeSchema,
26
+ getDataResourceAsRequest: () => getDataResourceAsRequest,
27
+ getDataResourceHeaders: () => getDataResourceHeaders,
28
+ getDataResourceQueryString: () => getDataResourceQueryString,
29
+ getDataResourceUrl: () => getDataResourceUrl,
30
+ mergedDataTypeSchema: () => mergedDataTypeSchema,
31
+ preRequestEdgehancerDataResourceResultSchema: () => preRequestEdgehancerDataResourceResultSchema,
32
+ preRequestEdgehancerResultSchema: () => preRequestEdgehancerResultSchema,
33
+ requestEdgehancerDataResourceResolutionResultSchema: () => requestEdgehancerDataResourceResolutionResultSchema,
34
+ requestEdgehancerResultSchema: () => requestEdgehancerResultSchema,
35
+ resolveBatchFetchIds: () => resolveBatchFetchIds
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+
39
+ // src/batchUtils.ts
40
+ function convertBatchResultsToEdgehancerResult({
41
+ batch,
42
+ batchFetchIds: { invalidBatchIndices, validIdToOriginalIndexMap },
43
+ batchResults,
44
+ resolveIdFromBatchResultFn,
45
+ knownInvalidErrorMessage = "batch request ID could not be read from the data resource",
46
+ missingBatchResultErrorMessage = () => "batch request did not return a result for the data resource ID"
47
+ }) {
48
+ const results = new Array(batch.length);
49
+ if (!Array.isArray(batchResults)) {
50
+ throw new Error(`batchResults is not an array (got ${typeof batchResults})`);
51
+ }
52
+ for (const batchResult of batchResults) {
53
+ const resultId = resolveIdFromBatchResultFn(batchResult);
54
+ const batchIndex = validIdToOriginalIndexMap.get(resultId);
55
+ if (batchIndex !== void 0) {
56
+ results[batchIndex] = {
57
+ result: batchResult
58
+ };
59
+ }
60
+ }
61
+ for (const batchIndex of invalidBatchIndices) {
62
+ results[batchIndex] = {
63
+ errors: [knownInvalidErrorMessage]
64
+ };
65
+ }
66
+ for (let batchIndex = 0; batchIndex < results.length; batchIndex++) {
67
+ if (results[batchIndex] === void 0) {
68
+ results[batchIndex] = {
69
+ errors: [missingBatchResultErrorMessage(batch[batchIndex])]
70
+ };
71
+ }
72
+ }
73
+ return results;
74
+ }
75
+ function resolveBatchFetchIds(batch, resolveBatchItemIdFn) {
76
+ const result = {
77
+ invalidBatchIndices: /* @__PURE__ */ new Set(),
78
+ validIds: [],
79
+ validIdToOriginalIndexMap: /* @__PURE__ */ new Map()
80
+ };
81
+ batch.forEach((context, batchIndex) => {
82
+ const id = resolveBatchItemIdFn(context);
83
+ if (id === void 0) {
84
+ result.invalidBatchIndices.add(batchIndex);
85
+ return;
86
+ }
87
+ result.validIdToOriginalIndexMap.set(id, batchIndex);
88
+ result.validIds.push(id);
89
+ });
90
+ return result;
91
+ }
92
+
93
+ // src/fetchUtils.ts
94
+ function getDataResourceAsRequest(data) {
95
+ var _a;
96
+ const method = (_a = data.method) != null ? _a : "GET";
97
+ const body = method === "POST" ? data.body : void 0;
98
+ const headers = getDataResourceHeaders(data);
99
+ const url = getDataResourceUrl(data);
100
+ return new Request(url, { method, headers, body });
101
+ }
102
+ function getDataResourceUrl(dataResource) {
103
+ const urlParts = dataResource.url.split("?");
104
+ const queryString = getDataResourceQueryString(dataResource);
105
+ const url = new URL(urlParts[0]).toString();
106
+ return url + (queryString.length > 0 ? `?${queryString}` : "");
107
+ }
108
+ function getDataResourceQueryString({ parameters, url }) {
109
+ const urlParts = url.split("?");
110
+ const searchParams = copyKeyValuePairs(parameters, new URLSearchParams(urlParts[1]));
111
+ return Array.from(searchParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
112
+ }
113
+ function getDataResourceHeaders({ headers }) {
114
+ return copyKeyValuePairs(headers, new Headers());
115
+ }
116
+ function copyKeyValuePairs(source, target) {
117
+ if (Array.isArray(source)) {
118
+ [...source].sort((a, b) => a.key.localeCompare(b.key)).forEach(({ key, value, omitIfEmpty }) => {
119
+ if (value || !omitIfEmpty) {
120
+ target.append(key, value);
121
+ }
122
+ });
123
+ } else if (source) {
124
+ Object.keys(source).sort((a, b) => a.localeCompare(b)).forEach((key) => {
125
+ target.append(key, source[key]);
126
+ });
127
+ }
128
+ return target;
129
+ }
130
+
131
+ // src/preRequest.ts
132
+ var import_zod2 = require("zod");
133
+
134
+ // src/shared.ts
135
+ var import_tsafe = require("tsafe");
136
+ var import_zod = require("zod");
137
+ var parameterDefinitionSchema = import_zod.z.object({
138
+ key: import_zod.z.string(),
139
+ value: import_zod.z.string(),
140
+ omitIfEmpty: import_zod.z.boolean().optional()
141
+ });
142
+ var variableDefinitionSchema = import_zod.z.object({
143
+ displayName: import_zod.z.string().optional(),
144
+ type: import_zod.z.string().optional(),
145
+ default: import_zod.z.string(),
146
+ helpText: import_zod.z.string().optional(),
147
+ order: import_zod.z.number().optional(),
148
+ source: import_zod.z.string().optional()
149
+ });
150
+ var customEdgehancerDefinitionSchema = import_zod.z.object({
151
+ preRequest: import_zod.z.string().optional(),
152
+ request: import_zod.z.string().optional()
153
+ });
154
+ var mergedDataTypeSchema = import_zod.z.object({
155
+ id: import_zod.z.string(),
156
+ displayName: import_zod.z.string(),
157
+ archetype: import_zod.z.string().optional(),
158
+ allowedOnComponents: import_zod.z.array(import_zod.z.string()).optional(),
159
+ badgeIconUrl: import_zod.z.string().optional(),
160
+ connectorType: import_zod.z.string(),
161
+ url: import_zod.z.string(),
162
+ headers: import_zod.z.array(parameterDefinitionSchema).optional(),
163
+ parameters: import_zod.z.array(parameterDefinitionSchema).optional(),
164
+ body: import_zod.z.string().optional(),
165
+ method: import_zod.z.enum(["GET", "POST", "HEAD"]),
166
+ variables: import_zod.z.record(variableDefinitionSchema).optional(),
167
+ custom: import_zod.z.record(import_zod.z.unknown()).optional(),
168
+ ttl: import_zod.z.number().optional(),
169
+ purgeKey: import_zod.z.string().optional(),
170
+ localeMapping: import_zod.z.record(import_zod.z.string()).optional(),
171
+ edgehancer: customEdgehancerDefinitionSchema.optional(),
172
+ uiBadgeText: import_zod.z.string().max(12).optional()
173
+ });
174
+ (0, import_tsafe.assert)();
175
+ var dataResourceSchema = import_zod.z.union([
176
+ import_zod.z.string(),
177
+ import_zod.z.object({}).catchall(import_zod.z.unknown()),
178
+ import_zod.z.number(),
179
+ import_zod.z.boolean(),
180
+ import_zod.z.array(import_zod.z.unknown()),
181
+ import_zod.z.undefined()
182
+ ]);
183
+
184
+ // src/preRequest.ts
185
+ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
186
+ edgehancer: true,
187
+ allowedOnComponents: true,
188
+ badgeIconUrl: true,
189
+ displayName: true,
190
+ id: true,
191
+ purgeKey: true,
192
+ variables: true
193
+ });
194
+ var preRequestEdgehancerDataResourceResultSchema = import_zod2.z.strictObject({
195
+ errors: import_zod2.z.array(import_zod2.z.string()).optional(),
196
+ warnings: import_zod2.z.array(import_zod2.z.string()).optional(),
197
+ dataResource: edgehancerMergedDataTypeSchema
198
+ });
199
+ var preRequestEdgehancerResultSchema = import_zod2.z.strictObject({
200
+ dataResources: import_zod2.z.array(preRequestEdgehancerDataResourceResultSchema)
201
+ });
202
+
203
+ // src/request.ts
204
+ var import_zod3 = require("zod");
205
+ var requestEdgehancerDataResourceResolutionResultSchema = import_zod3.z.strictObject({
206
+ errors: import_zod3.z.array(import_zod3.z.string()).optional().describe(
207
+ "Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
208
+ ),
209
+ warnings: import_zod3.z.array(import_zod3.z.string()).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
210
+ surrogateKeys: import_zod3.z.array(import_zod3.z.string()).optional().describe(
211
+ "Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
212
+ ),
213
+ result: dataResourceSchema.describe("The result of fetching the data resource")
214
+ });
215
+ var requestEdgehancerResultSchema = import_zod3.z.strictObject({
216
+ results: import_zod3.z.array(requestEdgehancerDataResourceResolutionResultSchema)
217
+ });
218
+ // Annotate the CommonJS export names for ESM import in node:
219
+ 0 && (module.exports = {
220
+ convertBatchResultsToEdgehancerResult,
221
+ dataResourceSchema,
222
+ edgehancerMergedDataTypeSchema,
223
+ getDataResourceAsRequest,
224
+ getDataResourceHeaders,
225
+ getDataResourceQueryString,
226
+ getDataResourceUrl,
227
+ mergedDataTypeSchema,
228
+ preRequestEdgehancerDataResourceResultSchema,
229
+ preRequestEdgehancerResultSchema,
230
+ requestEdgehancerDataResourceResolutionResultSchema,
231
+ requestEdgehancerResultSchema,
232
+ resolveBatchFetchIds
233
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,194 @@
1
+ // src/batchUtils.ts
2
+ function convertBatchResultsToEdgehancerResult({
3
+ batch,
4
+ batchFetchIds: { invalidBatchIndices, validIdToOriginalIndexMap },
5
+ batchResults,
6
+ resolveIdFromBatchResultFn,
7
+ knownInvalidErrorMessage = "batch request ID could not be read from the data resource",
8
+ missingBatchResultErrorMessage = () => "batch request did not return a result for the data resource ID"
9
+ }) {
10
+ const results = new Array(batch.length);
11
+ if (!Array.isArray(batchResults)) {
12
+ throw new Error(`batchResults is not an array (got ${typeof batchResults})`);
13
+ }
14
+ for (const batchResult of batchResults) {
15
+ const resultId = resolveIdFromBatchResultFn(batchResult);
16
+ const batchIndex = validIdToOriginalIndexMap.get(resultId);
17
+ if (batchIndex !== void 0) {
18
+ results[batchIndex] = {
19
+ result: batchResult
20
+ };
21
+ }
22
+ }
23
+ for (const batchIndex of invalidBatchIndices) {
24
+ results[batchIndex] = {
25
+ errors: [knownInvalidErrorMessage]
26
+ };
27
+ }
28
+ for (let batchIndex = 0; batchIndex < results.length; batchIndex++) {
29
+ if (results[batchIndex] === void 0) {
30
+ results[batchIndex] = {
31
+ errors: [missingBatchResultErrorMessage(batch[batchIndex])]
32
+ };
33
+ }
34
+ }
35
+ return results;
36
+ }
37
+ function resolveBatchFetchIds(batch, resolveBatchItemIdFn) {
38
+ const result = {
39
+ invalidBatchIndices: /* @__PURE__ */ new Set(),
40
+ validIds: [],
41
+ validIdToOriginalIndexMap: /* @__PURE__ */ new Map()
42
+ };
43
+ batch.forEach((context, batchIndex) => {
44
+ const id = resolveBatchItemIdFn(context);
45
+ if (id === void 0) {
46
+ result.invalidBatchIndices.add(batchIndex);
47
+ return;
48
+ }
49
+ result.validIdToOriginalIndexMap.set(id, batchIndex);
50
+ result.validIds.push(id);
51
+ });
52
+ return result;
53
+ }
54
+
55
+ // src/fetchUtils.ts
56
+ function getDataResourceAsRequest(data) {
57
+ var _a;
58
+ const method = (_a = data.method) != null ? _a : "GET";
59
+ const body = method === "POST" ? data.body : void 0;
60
+ const headers = getDataResourceHeaders(data);
61
+ const url = getDataResourceUrl(data);
62
+ return new Request(url, { method, headers, body });
63
+ }
64
+ function getDataResourceUrl(dataResource) {
65
+ const urlParts = dataResource.url.split("?");
66
+ const queryString = getDataResourceQueryString(dataResource);
67
+ const url = new URL(urlParts[0]).toString();
68
+ return url + (queryString.length > 0 ? `?${queryString}` : "");
69
+ }
70
+ function getDataResourceQueryString({ parameters, url }) {
71
+ const urlParts = url.split("?");
72
+ const searchParams = copyKeyValuePairs(parameters, new URLSearchParams(urlParts[1]));
73
+ return Array.from(searchParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
74
+ }
75
+ function getDataResourceHeaders({ headers }) {
76
+ return copyKeyValuePairs(headers, new Headers());
77
+ }
78
+ function copyKeyValuePairs(source, target) {
79
+ if (Array.isArray(source)) {
80
+ [...source].sort((a, b) => a.key.localeCompare(b.key)).forEach(({ key, value, omitIfEmpty }) => {
81
+ if (value || !omitIfEmpty) {
82
+ target.append(key, value);
83
+ }
84
+ });
85
+ } else if (source) {
86
+ Object.keys(source).sort((a, b) => a.localeCompare(b)).forEach((key) => {
87
+ target.append(key, source[key]);
88
+ });
89
+ }
90
+ return target;
91
+ }
92
+
93
+ // src/preRequest.ts
94
+ import { z as z2 } from "zod";
95
+
96
+ // src/shared.ts
97
+ import { assert } from "tsafe";
98
+ import { z } from "zod";
99
+ var parameterDefinitionSchema = z.object({
100
+ key: z.string(),
101
+ value: z.string(),
102
+ omitIfEmpty: z.boolean().optional()
103
+ });
104
+ var variableDefinitionSchema = z.object({
105
+ displayName: z.string().optional(),
106
+ type: z.string().optional(),
107
+ default: z.string(),
108
+ helpText: z.string().optional(),
109
+ order: z.number().optional(),
110
+ source: z.string().optional()
111
+ });
112
+ var customEdgehancerDefinitionSchema = z.object({
113
+ preRequest: z.string().optional(),
114
+ request: z.string().optional()
115
+ });
116
+ var mergedDataTypeSchema = z.object({
117
+ id: z.string(),
118
+ displayName: z.string(),
119
+ archetype: z.string().optional(),
120
+ allowedOnComponents: z.array(z.string()).optional(),
121
+ badgeIconUrl: z.string().optional(),
122
+ connectorType: z.string(),
123
+ url: z.string(),
124
+ headers: z.array(parameterDefinitionSchema).optional(),
125
+ parameters: z.array(parameterDefinitionSchema).optional(),
126
+ body: z.string().optional(),
127
+ method: z.enum(["GET", "POST", "HEAD"]),
128
+ variables: z.record(variableDefinitionSchema).optional(),
129
+ custom: z.record(z.unknown()).optional(),
130
+ ttl: z.number().optional(),
131
+ purgeKey: z.string().optional(),
132
+ localeMapping: z.record(z.string()).optional(),
133
+ edgehancer: customEdgehancerDefinitionSchema.optional(),
134
+ uiBadgeText: z.string().max(12).optional()
135
+ });
136
+ assert();
137
+ var dataResourceSchema = z.union([
138
+ z.string(),
139
+ z.object({}).catchall(z.unknown()),
140
+ z.number(),
141
+ z.boolean(),
142
+ z.array(z.unknown()),
143
+ z.undefined()
144
+ ]);
145
+
146
+ // src/preRequest.ts
147
+ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
148
+ edgehancer: true,
149
+ allowedOnComponents: true,
150
+ badgeIconUrl: true,
151
+ displayName: true,
152
+ id: true,
153
+ purgeKey: true,
154
+ variables: true
155
+ });
156
+ var preRequestEdgehancerDataResourceResultSchema = z2.strictObject({
157
+ errors: z2.array(z2.string()).optional(),
158
+ warnings: z2.array(z2.string()).optional(),
159
+ dataResource: edgehancerMergedDataTypeSchema
160
+ });
161
+ var preRequestEdgehancerResultSchema = z2.strictObject({
162
+ dataResources: z2.array(preRequestEdgehancerDataResourceResultSchema)
163
+ });
164
+
165
+ // src/request.ts
166
+ import { z as z3 } from "zod";
167
+ var requestEdgehancerDataResourceResolutionResultSchema = z3.strictObject({
168
+ errors: z3.array(z3.string()).optional().describe(
169
+ "Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
170
+ ),
171
+ warnings: z3.array(z3.string()).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
172
+ surrogateKeys: z3.array(z3.string()).optional().describe(
173
+ "Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
174
+ ),
175
+ result: dataResourceSchema.describe("The result of fetching the data resource")
176
+ });
177
+ var requestEdgehancerResultSchema = z3.strictObject({
178
+ results: z3.array(requestEdgehancerDataResourceResolutionResultSchema)
179
+ });
180
+ export {
181
+ convertBatchResultsToEdgehancerResult,
182
+ dataResourceSchema,
183
+ edgehancerMergedDataTypeSchema,
184
+ getDataResourceAsRequest,
185
+ getDataResourceHeaders,
186
+ getDataResourceQueryString,
187
+ getDataResourceUrl,
188
+ mergedDataTypeSchema,
189
+ preRequestEdgehancerDataResourceResultSchema,
190
+ preRequestEdgehancerResultSchema,
191
+ requestEdgehancerDataResourceResolutionResultSchema,
192
+ requestEdgehancerResultSchema,
193
+ resolveBatchFetchIds
194
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@uniformdev/mesh-edgehancer-sdk",
3
+ "version": "19.79.1-alpha.13+608a273da",
4
+ "description": "Uniform Mesh Edgehancer SDK",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.esm.js",
8
+ "exports": {
9
+ "import": {
10
+ "types": "./dist/index.d.mts",
11
+ "node": "./dist/index.mjs",
12
+ "default": "./dist/index.esm.js"
13
+ },
14
+ "require": "./dist/index.js"
15
+ },
16
+ "types": "./dist/index.d.ts",
17
+ "sideEffects": false,
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsup --watch",
21
+ "clean": "rimraf dist",
22
+ "test": "jest --maxWorkers=1 --passWithNoTests",
23
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
24
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
25
+ "document": "api-extractor run --local"
26
+ },
27
+ "files": [
28
+ "/dist"
29
+ ],
30
+ "dependencies": {
31
+ "@uniformdev/canvas": "19.79.1-alpha.13+608a273da",
32
+ "tsafe": "1.6.5",
33
+ "zod": "3.22.4"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "gitHead": "608a273da87aa432f17b2c8ce15d747dadab0cd1"
39
+ }