@deliverart/sdk-js-core 2.6.7 → 2.6.9
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/index.cjs +90 -2
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +86 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,10 @@ __export(index_exports, {
|
|
|
33
33
|
AbstractApiRequest: () => AbstractApiRequest,
|
|
34
34
|
InputValidationError: () => InputValidationError,
|
|
35
35
|
OutputValidationError: () => OutputValidationError,
|
|
36
|
-
createApiClient: () => createApiClient
|
|
36
|
+
createApiClient: () => createApiClient,
|
|
37
|
+
deserializeFromClient: () => deserializeFromClient,
|
|
38
|
+
serializeForClient: () => serializeForClient,
|
|
39
|
+
serializedIriObjectSchema: () => serializedIriObjectSchema
|
|
37
40
|
});
|
|
38
41
|
module.exports = __toCommonJS(index_exports);
|
|
39
42
|
|
|
@@ -11156,6 +11159,37 @@ var webhookEntities = [
|
|
|
11156
11159
|
"App\\Entity\\PointOfSale"
|
|
11157
11160
|
];
|
|
11158
11161
|
var webhookEntitySchema = external_exports.enum(webhookEntities);
|
|
11162
|
+
var isUuid = (s) => /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i.test(s);
|
|
11163
|
+
var IriObject = class {
|
|
11164
|
+
constructor(iri, pattern) {
|
|
11165
|
+
this.iri = iri;
|
|
11166
|
+
this.params = this.extractParams(iri, pattern);
|
|
11167
|
+
this.__pattern = pattern;
|
|
11168
|
+
}
|
|
11169
|
+
extractParams(iri, pattern) {
|
|
11170
|
+
const iriParts = iri.split("/").filter(Boolean);
|
|
11171
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
11172
|
+
const result = {};
|
|
11173
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
11174
|
+
const part = patternParts[i];
|
|
11175
|
+
if (part.startsWith(":")) {
|
|
11176
|
+
const key = part.slice(1);
|
|
11177
|
+
const value = iriParts[i];
|
|
11178
|
+
if (!isUuid(value)) {
|
|
11179
|
+
throw new Error(`Invalid UUID for parameter "${key}": "${value}"`);
|
|
11180
|
+
}
|
|
11181
|
+
result[key] = value;
|
|
11182
|
+
}
|
|
11183
|
+
}
|
|
11184
|
+
return result;
|
|
11185
|
+
}
|
|
11186
|
+
toString() {
|
|
11187
|
+
return this.iri;
|
|
11188
|
+
}
|
|
11189
|
+
toJSON() {
|
|
11190
|
+
return this.iri;
|
|
11191
|
+
}
|
|
11192
|
+
};
|
|
11159
11193
|
var addressSchema = external_exports.object({
|
|
11160
11194
|
line1: external_exports.string().nullable().optional(),
|
|
11161
11195
|
line2: external_exports.string().nullable().optional(),
|
|
@@ -22607,10 +22641,64 @@ function createApiClient(config3) {
|
|
|
22607
22641
|
};
|
|
22608
22642
|
return base;
|
|
22609
22643
|
}
|
|
22644
|
+
|
|
22645
|
+
// src/serialization.ts
|
|
22646
|
+
var serializedIriObjectSchema = external_exports2.object({
|
|
22647
|
+
iri: external_exports2.string().min(1),
|
|
22648
|
+
params: external_exports2.record(external_exports2.string(), external_exports2.string()),
|
|
22649
|
+
__pattern: external_exports2.string().min(1)
|
|
22650
|
+
}).strict();
|
|
22651
|
+
function isSerializedIriObject(input2) {
|
|
22652
|
+
return typeof input2 === "object" && input2 !== null && "iri" in input2 && "params" in input2 && "__pattern" in input2 && typeof input2.iri === "string" && typeof input2.__pattern === "string" && typeof input2.params === "object";
|
|
22653
|
+
}
|
|
22654
|
+
function deserializeIri(s) {
|
|
22655
|
+
return new IriObject(s.iri, s.__pattern);
|
|
22656
|
+
}
|
|
22657
|
+
function serializeForClient(input2) {
|
|
22658
|
+
if (input2 instanceof IriObject) {
|
|
22659
|
+
return {
|
|
22660
|
+
iri: input2.iri,
|
|
22661
|
+
params: input2.params,
|
|
22662
|
+
__pattern: input2.__pattern
|
|
22663
|
+
// qui P è literal
|
|
22664
|
+
};
|
|
22665
|
+
}
|
|
22666
|
+
if (Array.isArray(input2)) {
|
|
22667
|
+
return input2.map((item) => serializeForClient(item));
|
|
22668
|
+
}
|
|
22669
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22670
|
+
const result = {};
|
|
22671
|
+
for (const key in input2) {
|
|
22672
|
+
const value = input2[key];
|
|
22673
|
+
result[key] = serializeForClient(value);
|
|
22674
|
+
}
|
|
22675
|
+
return result;
|
|
22676
|
+
}
|
|
22677
|
+
return input2;
|
|
22678
|
+
}
|
|
22679
|
+
function deserializeFromClient(input2) {
|
|
22680
|
+
if (isSerializedIriObject(input2)) {
|
|
22681
|
+
return deserializeIri(input2);
|
|
22682
|
+
}
|
|
22683
|
+
if (Array.isArray(input2)) {
|
|
22684
|
+
return input2.map((item) => deserializeFromClient(item));
|
|
22685
|
+
}
|
|
22686
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22687
|
+
const result = {};
|
|
22688
|
+
for (const key in input2) {
|
|
22689
|
+
result[key] = deserializeFromClient(input2[key]);
|
|
22690
|
+
}
|
|
22691
|
+
return result;
|
|
22692
|
+
}
|
|
22693
|
+
return input2;
|
|
22694
|
+
}
|
|
22610
22695
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22611
22696
|
0 && (module.exports = {
|
|
22612
22697
|
AbstractApiRequest,
|
|
22613
22698
|
InputValidationError,
|
|
22614
22699
|
OutputValidationError,
|
|
22615
|
-
createApiClient
|
|
22700
|
+
createApiClient,
|
|
22701
|
+
deserializeFromClient,
|
|
22702
|
+
serializeForClient,
|
|
22703
|
+
serializedIriObjectSchema
|
|
22616
22704
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ZodType, input, output, ZodError } from 'zod';
|
|
1
|
+
import { ZodType, input, output, ZodError, z } from 'zod';
|
|
2
|
+
import { IriObject } from '@deliverart/sdk-js-global-types';
|
|
2
3
|
|
|
3
4
|
type ApiExtension = Record<string, unknown>;
|
|
4
5
|
interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
|
|
@@ -101,4 +102,24 @@ declare class OutputValidationError extends Error {
|
|
|
101
102
|
constructor(issues: ZodIssue[]);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
declare const serializedIriObjectSchema: z.ZodObject<{
|
|
106
|
+
iri: z.ZodString;
|
|
107
|
+
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
108
|
+
__pattern: z.ZodString;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
type SerializedIriObject<TPattern extends string = string> = {
|
|
111
|
+
iri: string;
|
|
112
|
+
params: Record<string, string>;
|
|
113
|
+
__pattern: TPattern;
|
|
114
|
+
};
|
|
115
|
+
type DeepDeserialized<T> = T extends SerializedIriObject<infer P> ? IriObject<P> : T extends Array<infer U> ? DeepDeserialized<U>[] : T extends object ? {
|
|
116
|
+
[K in keyof T]: DeepDeserialized<T[K]>;
|
|
117
|
+
} : T;
|
|
118
|
+
type DeepSerialized<T> = T extends IriObject<infer P> ? SerializedIriObject<P> : T extends Array<infer U> ? DeepSerialized<U>[] : T extends object ? {
|
|
119
|
+
[K in keyof T]: DeepSerialized<T[K]>;
|
|
120
|
+
} : T;
|
|
121
|
+
declare function serializeForClient<T>(input: T): DeepSerialized<T>;
|
|
122
|
+
declare function deserializeFromClient<T extends SerializedIriObject<P>, P extends string>(input: T): IriObject<P>;
|
|
123
|
+
declare function deserializeFromClient<T>(input: T): DeepDeserialized<T>;
|
|
124
|
+
|
|
125
|
+
export { AbstractApiRequest, type ApiClient, type ApiClientPlugin, type ApiExtension, type DeepDeserialized, type DeepSerialized, InputValidationError, OutputValidationError, type SerializedIriObject, type UnpaginatedResponse, createApiClient, deserializeFromClient, serializeForClient, serializedIriObjectSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ZodType, input, output, ZodError } from 'zod';
|
|
1
|
+
import { ZodType, input, output, ZodError, z } from 'zod';
|
|
2
|
+
import { IriObject } from '@deliverart/sdk-js-global-types';
|
|
2
3
|
|
|
3
4
|
type ApiExtension = Record<string, unknown>;
|
|
4
5
|
interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
|
|
@@ -101,4 +102,24 @@ declare class OutputValidationError extends Error {
|
|
|
101
102
|
constructor(issues: ZodIssue[]);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
declare const serializedIriObjectSchema: z.ZodObject<{
|
|
106
|
+
iri: z.ZodString;
|
|
107
|
+
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
108
|
+
__pattern: z.ZodString;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
type SerializedIriObject<TPattern extends string = string> = {
|
|
111
|
+
iri: string;
|
|
112
|
+
params: Record<string, string>;
|
|
113
|
+
__pattern: TPattern;
|
|
114
|
+
};
|
|
115
|
+
type DeepDeserialized<T> = T extends SerializedIriObject<infer P> ? IriObject<P> : T extends Array<infer U> ? DeepDeserialized<U>[] : T extends object ? {
|
|
116
|
+
[K in keyof T]: DeepDeserialized<T[K]>;
|
|
117
|
+
} : T;
|
|
118
|
+
type DeepSerialized<T> = T extends IriObject<infer P> ? SerializedIriObject<P> : T extends Array<infer U> ? DeepSerialized<U>[] : T extends object ? {
|
|
119
|
+
[K in keyof T]: DeepSerialized<T[K]>;
|
|
120
|
+
} : T;
|
|
121
|
+
declare function serializeForClient<T>(input: T): DeepSerialized<T>;
|
|
122
|
+
declare function deserializeFromClient<T extends SerializedIriObject<P>, P extends string>(input: T): IriObject<P>;
|
|
123
|
+
declare function deserializeFromClient<T>(input: T): DeepDeserialized<T>;
|
|
124
|
+
|
|
125
|
+
export { AbstractApiRequest, type ApiClient, type ApiClientPlugin, type ApiExtension, type DeepDeserialized, type DeepSerialized, InputValidationError, OutputValidationError, type SerializedIriObject, type UnpaginatedResponse, createApiClient, deserializeFromClient, serializeForClient, serializedIriObjectSchema };
|
package/dist/index.js
CHANGED
|
@@ -11123,6 +11123,37 @@ var webhookEntities = [
|
|
|
11123
11123
|
"App\\Entity\\PointOfSale"
|
|
11124
11124
|
];
|
|
11125
11125
|
var webhookEntitySchema = external_exports.enum(webhookEntities);
|
|
11126
|
+
var isUuid = (s) => /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i.test(s);
|
|
11127
|
+
var IriObject = class {
|
|
11128
|
+
constructor(iri, pattern) {
|
|
11129
|
+
this.iri = iri;
|
|
11130
|
+
this.params = this.extractParams(iri, pattern);
|
|
11131
|
+
this.__pattern = pattern;
|
|
11132
|
+
}
|
|
11133
|
+
extractParams(iri, pattern) {
|
|
11134
|
+
const iriParts = iri.split("/").filter(Boolean);
|
|
11135
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
11136
|
+
const result = {};
|
|
11137
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
11138
|
+
const part = patternParts[i];
|
|
11139
|
+
if (part.startsWith(":")) {
|
|
11140
|
+
const key = part.slice(1);
|
|
11141
|
+
const value = iriParts[i];
|
|
11142
|
+
if (!isUuid(value)) {
|
|
11143
|
+
throw new Error(`Invalid UUID for parameter "${key}": "${value}"`);
|
|
11144
|
+
}
|
|
11145
|
+
result[key] = value;
|
|
11146
|
+
}
|
|
11147
|
+
}
|
|
11148
|
+
return result;
|
|
11149
|
+
}
|
|
11150
|
+
toString() {
|
|
11151
|
+
return this.iri;
|
|
11152
|
+
}
|
|
11153
|
+
toJSON() {
|
|
11154
|
+
return this.iri;
|
|
11155
|
+
}
|
|
11156
|
+
};
|
|
11126
11157
|
var addressSchema = external_exports.object({
|
|
11127
11158
|
line1: external_exports.string().nullable().optional(),
|
|
11128
11159
|
line2: external_exports.string().nullable().optional(),
|
|
@@ -22574,9 +22605,63 @@ function createApiClient(config3) {
|
|
|
22574
22605
|
};
|
|
22575
22606
|
return base;
|
|
22576
22607
|
}
|
|
22608
|
+
|
|
22609
|
+
// src/serialization.ts
|
|
22610
|
+
var serializedIriObjectSchema = external_exports2.object({
|
|
22611
|
+
iri: external_exports2.string().min(1),
|
|
22612
|
+
params: external_exports2.record(external_exports2.string(), external_exports2.string()),
|
|
22613
|
+
__pattern: external_exports2.string().min(1)
|
|
22614
|
+
}).strict();
|
|
22615
|
+
function isSerializedIriObject(input2) {
|
|
22616
|
+
return typeof input2 === "object" && input2 !== null && "iri" in input2 && "params" in input2 && "__pattern" in input2 && typeof input2.iri === "string" && typeof input2.__pattern === "string" && typeof input2.params === "object";
|
|
22617
|
+
}
|
|
22618
|
+
function deserializeIri(s) {
|
|
22619
|
+
return new IriObject(s.iri, s.__pattern);
|
|
22620
|
+
}
|
|
22621
|
+
function serializeForClient(input2) {
|
|
22622
|
+
if (input2 instanceof IriObject) {
|
|
22623
|
+
return {
|
|
22624
|
+
iri: input2.iri,
|
|
22625
|
+
params: input2.params,
|
|
22626
|
+
__pattern: input2.__pattern
|
|
22627
|
+
// qui P è literal
|
|
22628
|
+
};
|
|
22629
|
+
}
|
|
22630
|
+
if (Array.isArray(input2)) {
|
|
22631
|
+
return input2.map((item) => serializeForClient(item));
|
|
22632
|
+
}
|
|
22633
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22634
|
+
const result = {};
|
|
22635
|
+
for (const key in input2) {
|
|
22636
|
+
const value = input2[key];
|
|
22637
|
+
result[key] = serializeForClient(value);
|
|
22638
|
+
}
|
|
22639
|
+
return result;
|
|
22640
|
+
}
|
|
22641
|
+
return input2;
|
|
22642
|
+
}
|
|
22643
|
+
function deserializeFromClient(input2) {
|
|
22644
|
+
if (isSerializedIriObject(input2)) {
|
|
22645
|
+
return deserializeIri(input2);
|
|
22646
|
+
}
|
|
22647
|
+
if (Array.isArray(input2)) {
|
|
22648
|
+
return input2.map((item) => deserializeFromClient(item));
|
|
22649
|
+
}
|
|
22650
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22651
|
+
const result = {};
|
|
22652
|
+
for (const key in input2) {
|
|
22653
|
+
result[key] = deserializeFromClient(input2[key]);
|
|
22654
|
+
}
|
|
22655
|
+
return result;
|
|
22656
|
+
}
|
|
22657
|
+
return input2;
|
|
22658
|
+
}
|
|
22577
22659
|
export {
|
|
22578
22660
|
AbstractApiRequest,
|
|
22579
22661
|
InputValidationError,
|
|
22580
22662
|
OutputValidationError,
|
|
22581
|
-
createApiClient
|
|
22663
|
+
createApiClient,
|
|
22664
|
+
deserializeFromClient,
|
|
22665
|
+
serializeForClient,
|
|
22666
|
+
serializedIriObjectSchema
|
|
22582
22667
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deliverart/sdk-js-core",
|
|
3
3
|
"description": "Core SDK for DeliverArt, providing essential functionalities and utilities.",
|
|
4
|
-
"version": "2.6.
|
|
4
|
+
"version": "2.6.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/qs": "^6.14.0",
|
|
28
|
-
"@deliverart/sdk-js-global-types": "2.6.
|
|
28
|
+
"@deliverart/sdk-js-global-types": "2.6.9"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsup src/index.ts --dts --format esm,cjs",
|