@deliverart/sdk-js-core 2.6.8 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +92 -2
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +88 -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
|
|
|
@@ -11139,6 +11142,8 @@ var paymentStatuses = [
|
|
|
11139
11142
|
"failed"
|
|
11140
11143
|
];
|
|
11141
11144
|
var paymentStatusSchema = external_exports.enum(paymentStatuses);
|
|
11145
|
+
var printerProtocols = ["esc_pos"];
|
|
11146
|
+
var printerProtocolSchema = external_exports.enum(printerProtocols);
|
|
11142
11147
|
var webhookEvents = ["create", "update", "delete"];
|
|
11143
11148
|
var webhookEventSchema = external_exports.enum(webhookEvents);
|
|
11144
11149
|
var webhookLogStatuses = ["pending", "success", "failed", "timeout"];
|
|
@@ -11156,6 +11161,37 @@ var webhookEntities = [
|
|
|
11156
11161
|
"App\\Entity\\PointOfSale"
|
|
11157
11162
|
];
|
|
11158
11163
|
var webhookEntitySchema = external_exports.enum(webhookEntities);
|
|
11164
|
+
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);
|
|
11165
|
+
var IriObject = class {
|
|
11166
|
+
constructor(iri, pattern) {
|
|
11167
|
+
this.iri = iri;
|
|
11168
|
+
this.params = this.extractParams(iri, pattern);
|
|
11169
|
+
this.__pattern = pattern;
|
|
11170
|
+
}
|
|
11171
|
+
extractParams(iri, pattern) {
|
|
11172
|
+
const iriParts = iri.split("/").filter(Boolean);
|
|
11173
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
11174
|
+
const result = {};
|
|
11175
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
11176
|
+
const part = patternParts[i];
|
|
11177
|
+
if (part.startsWith(":")) {
|
|
11178
|
+
const key = part.slice(1);
|
|
11179
|
+
const value = iriParts[i];
|
|
11180
|
+
if (!isUuid(value)) {
|
|
11181
|
+
throw new Error(`Invalid UUID for parameter "${key}": "${value}"`);
|
|
11182
|
+
}
|
|
11183
|
+
result[key] = value;
|
|
11184
|
+
}
|
|
11185
|
+
}
|
|
11186
|
+
return result;
|
|
11187
|
+
}
|
|
11188
|
+
toString() {
|
|
11189
|
+
return this.iri;
|
|
11190
|
+
}
|
|
11191
|
+
toJSON() {
|
|
11192
|
+
return this.iri;
|
|
11193
|
+
}
|
|
11194
|
+
};
|
|
11159
11195
|
var addressSchema = external_exports.object({
|
|
11160
11196
|
line1: external_exports.string().nullable().optional(),
|
|
11161
11197
|
line2: external_exports.string().nullable().optional(),
|
|
@@ -22607,10 +22643,64 @@ function createApiClient(config3) {
|
|
|
22607
22643
|
};
|
|
22608
22644
|
return base;
|
|
22609
22645
|
}
|
|
22646
|
+
|
|
22647
|
+
// src/serialization.ts
|
|
22648
|
+
var serializedIriObjectSchema = external_exports2.object({
|
|
22649
|
+
iri: external_exports2.string().min(1),
|
|
22650
|
+
params: external_exports2.record(external_exports2.string(), external_exports2.string()),
|
|
22651
|
+
__pattern: external_exports2.string().min(1)
|
|
22652
|
+
}).strict();
|
|
22653
|
+
function isSerializedIriObject(input2) {
|
|
22654
|
+
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";
|
|
22655
|
+
}
|
|
22656
|
+
function deserializeIri(s) {
|
|
22657
|
+
return new IriObject(s.iri, s.__pattern);
|
|
22658
|
+
}
|
|
22659
|
+
function serializeForClient(input2) {
|
|
22660
|
+
if (input2 instanceof IriObject) {
|
|
22661
|
+
return {
|
|
22662
|
+
iri: input2.iri,
|
|
22663
|
+
params: input2.params,
|
|
22664
|
+
__pattern: input2.__pattern
|
|
22665
|
+
// qui P è literal
|
|
22666
|
+
};
|
|
22667
|
+
}
|
|
22668
|
+
if (Array.isArray(input2)) {
|
|
22669
|
+
return input2.map((item) => serializeForClient(item));
|
|
22670
|
+
}
|
|
22671
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22672
|
+
const result = {};
|
|
22673
|
+
for (const key in input2) {
|
|
22674
|
+
const value = input2[key];
|
|
22675
|
+
result[key] = serializeForClient(value);
|
|
22676
|
+
}
|
|
22677
|
+
return result;
|
|
22678
|
+
}
|
|
22679
|
+
return input2;
|
|
22680
|
+
}
|
|
22681
|
+
function deserializeFromClient(input2) {
|
|
22682
|
+
if (isSerializedIriObject(input2)) {
|
|
22683
|
+
return deserializeIri(input2);
|
|
22684
|
+
}
|
|
22685
|
+
if (Array.isArray(input2)) {
|
|
22686
|
+
return input2.map((item) => deserializeFromClient(item));
|
|
22687
|
+
}
|
|
22688
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22689
|
+
const result = {};
|
|
22690
|
+
for (const key in input2) {
|
|
22691
|
+
result[key] = deserializeFromClient(input2[key]);
|
|
22692
|
+
}
|
|
22693
|
+
return result;
|
|
22694
|
+
}
|
|
22695
|
+
return input2;
|
|
22696
|
+
}
|
|
22610
22697
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22611
22698
|
0 && (module.exports = {
|
|
22612
22699
|
AbstractApiRequest,
|
|
22613
22700
|
InputValidationError,
|
|
22614
22701
|
OutputValidationError,
|
|
22615
|
-
createApiClient
|
|
22702
|
+
createApiClient,
|
|
22703
|
+
deserializeFromClient,
|
|
22704
|
+
serializeForClient,
|
|
22705
|
+
serializedIriObjectSchema
|
|
22616
22706
|
});
|
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
|
@@ -11106,6 +11106,8 @@ var paymentStatuses = [
|
|
|
11106
11106
|
"failed"
|
|
11107
11107
|
];
|
|
11108
11108
|
var paymentStatusSchema = external_exports.enum(paymentStatuses);
|
|
11109
|
+
var printerProtocols = ["esc_pos"];
|
|
11110
|
+
var printerProtocolSchema = external_exports.enum(printerProtocols);
|
|
11109
11111
|
var webhookEvents = ["create", "update", "delete"];
|
|
11110
11112
|
var webhookEventSchema = external_exports.enum(webhookEvents);
|
|
11111
11113
|
var webhookLogStatuses = ["pending", "success", "failed", "timeout"];
|
|
@@ -11123,6 +11125,37 @@ var webhookEntities = [
|
|
|
11123
11125
|
"App\\Entity\\PointOfSale"
|
|
11124
11126
|
];
|
|
11125
11127
|
var webhookEntitySchema = external_exports.enum(webhookEntities);
|
|
11128
|
+
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);
|
|
11129
|
+
var IriObject = class {
|
|
11130
|
+
constructor(iri, pattern) {
|
|
11131
|
+
this.iri = iri;
|
|
11132
|
+
this.params = this.extractParams(iri, pattern);
|
|
11133
|
+
this.__pattern = pattern;
|
|
11134
|
+
}
|
|
11135
|
+
extractParams(iri, pattern) {
|
|
11136
|
+
const iriParts = iri.split("/").filter(Boolean);
|
|
11137
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
11138
|
+
const result = {};
|
|
11139
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
11140
|
+
const part = patternParts[i];
|
|
11141
|
+
if (part.startsWith(":")) {
|
|
11142
|
+
const key = part.slice(1);
|
|
11143
|
+
const value = iriParts[i];
|
|
11144
|
+
if (!isUuid(value)) {
|
|
11145
|
+
throw new Error(`Invalid UUID for parameter "${key}": "${value}"`);
|
|
11146
|
+
}
|
|
11147
|
+
result[key] = value;
|
|
11148
|
+
}
|
|
11149
|
+
}
|
|
11150
|
+
return result;
|
|
11151
|
+
}
|
|
11152
|
+
toString() {
|
|
11153
|
+
return this.iri;
|
|
11154
|
+
}
|
|
11155
|
+
toJSON() {
|
|
11156
|
+
return this.iri;
|
|
11157
|
+
}
|
|
11158
|
+
};
|
|
11126
11159
|
var addressSchema = external_exports.object({
|
|
11127
11160
|
line1: external_exports.string().nullable().optional(),
|
|
11128
11161
|
line2: external_exports.string().nullable().optional(),
|
|
@@ -22574,9 +22607,63 @@ function createApiClient(config3) {
|
|
|
22574
22607
|
};
|
|
22575
22608
|
return base;
|
|
22576
22609
|
}
|
|
22610
|
+
|
|
22611
|
+
// src/serialization.ts
|
|
22612
|
+
var serializedIriObjectSchema = external_exports2.object({
|
|
22613
|
+
iri: external_exports2.string().min(1),
|
|
22614
|
+
params: external_exports2.record(external_exports2.string(), external_exports2.string()),
|
|
22615
|
+
__pattern: external_exports2.string().min(1)
|
|
22616
|
+
}).strict();
|
|
22617
|
+
function isSerializedIriObject(input2) {
|
|
22618
|
+
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";
|
|
22619
|
+
}
|
|
22620
|
+
function deserializeIri(s) {
|
|
22621
|
+
return new IriObject(s.iri, s.__pattern);
|
|
22622
|
+
}
|
|
22623
|
+
function serializeForClient(input2) {
|
|
22624
|
+
if (input2 instanceof IriObject) {
|
|
22625
|
+
return {
|
|
22626
|
+
iri: input2.iri,
|
|
22627
|
+
params: input2.params,
|
|
22628
|
+
__pattern: input2.__pattern
|
|
22629
|
+
// qui P è literal
|
|
22630
|
+
};
|
|
22631
|
+
}
|
|
22632
|
+
if (Array.isArray(input2)) {
|
|
22633
|
+
return input2.map((item) => serializeForClient(item));
|
|
22634
|
+
}
|
|
22635
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22636
|
+
const result = {};
|
|
22637
|
+
for (const key in input2) {
|
|
22638
|
+
const value = input2[key];
|
|
22639
|
+
result[key] = serializeForClient(value);
|
|
22640
|
+
}
|
|
22641
|
+
return result;
|
|
22642
|
+
}
|
|
22643
|
+
return input2;
|
|
22644
|
+
}
|
|
22645
|
+
function deserializeFromClient(input2) {
|
|
22646
|
+
if (isSerializedIriObject(input2)) {
|
|
22647
|
+
return deserializeIri(input2);
|
|
22648
|
+
}
|
|
22649
|
+
if (Array.isArray(input2)) {
|
|
22650
|
+
return input2.map((item) => deserializeFromClient(item));
|
|
22651
|
+
}
|
|
22652
|
+
if (input2 !== null && typeof input2 === "object") {
|
|
22653
|
+
const result = {};
|
|
22654
|
+
for (const key in input2) {
|
|
22655
|
+
result[key] = deserializeFromClient(input2[key]);
|
|
22656
|
+
}
|
|
22657
|
+
return result;
|
|
22658
|
+
}
|
|
22659
|
+
return input2;
|
|
22660
|
+
}
|
|
22577
22661
|
export {
|
|
22578
22662
|
AbstractApiRequest,
|
|
22579
22663
|
InputValidationError,
|
|
22580
22664
|
OutputValidationError,
|
|
22581
|
-
createApiClient
|
|
22665
|
+
createApiClient,
|
|
22666
|
+
deserializeFromClient,
|
|
22667
|
+
serializeForClient,
|
|
22668
|
+
serializedIriObjectSchema
|
|
22582
22669
|
};
|
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.
|
|
4
|
+
"version": "2.7.0",
|
|
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.
|
|
28
|
+
"@deliverart/sdk-js-global-types": "2.7.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsup src/index.ts --dts --format esm,cjs",
|