@mailoo/market 1.34.16 → 1.35.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/README.md +78 -7
- package/dist/chunk-BMXXTHKE.js +246 -0
- package/dist/chunk-BMXXTHKE.js.map +1 -0
- package/dist/chunk-OZGIU3QY.js +7 -0
- package/dist/chunk-OZGIU3QY.js.map +1 -0
- package/dist/chunk-XKKV5XLT.js +29 -0
- package/dist/chunk-XKKV5XLT.js.map +1 -0
- package/dist/client-BplmErft.d.cts +50 -0
- package/dist/client-Cju9fmhd.d.ts +50 -0
- package/dist/index-CiEG0zwt.d.cts +140 -0
- package/dist/index-CiEG0zwt.d.ts +140 -0
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/node/index.cjs +281 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +59 -0
- package/dist/node/index.d.ts +59 -0
- package/dist/node/index.js +19 -0
- package/dist/node/index.js.map +1 -0
- package/dist/routes/index.cjs +5 -1
- package/dist/routes/index.cjs.map +1 -1
- package/dist/routes/index.d.cts +2 -1
- package/dist/routes/index.d.ts +2 -1
- package/dist/routes/index.js +3 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/server/index.cjs +259 -62
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +3 -45
- package/dist/server/index.d.ts +3 -45
- package/dist/server/index.js +15 -3
- package/package.json +10 -4
- package/dist/chunk-NAJPNZ4L.js +0 -77
- package/dist/chunk-NAJPNZ4L.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** Framework-neutral server/job contracts. No API key belongs in browser code. */
|
|
2
|
+
declare const MAILOO_MARKET_INTEGRATION_PREFIX: "MAILOO_MARKET";
|
|
3
|
+
type MailooMarketConfig = {
|
|
4
|
+
apiBaseUrl: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
projectUid: string;
|
|
7
|
+
integrationId: string;
|
|
8
|
+
};
|
|
9
|
+
type MailooMarketRecord = Record<string, unknown>;
|
|
10
|
+
type MailooMarketErrorBody = null | boolean | number | string | MailooMarketErrorBody[] | {
|
|
11
|
+
[key: string]: MailooMarketErrorBody;
|
|
12
|
+
};
|
|
13
|
+
type MailooMarketApiError = {
|
|
14
|
+
code?: string | number;
|
|
15
|
+
message?: string;
|
|
16
|
+
details?: MailooMarketErrorBody;
|
|
17
|
+
};
|
|
18
|
+
type MailooMarketResult<T> = {
|
|
19
|
+
ok: true;
|
|
20
|
+
data: T;
|
|
21
|
+
status: number;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
status: number;
|
|
25
|
+
body?: MailooMarketErrorBody;
|
|
26
|
+
error?: MailooMarketApiError;
|
|
27
|
+
};
|
|
28
|
+
type MailooMarketProduct = MailooMarketRecord & {
|
|
29
|
+
id: string;
|
|
30
|
+
attributes?: Record<string, unknown>;
|
|
31
|
+
variants?: Array<{
|
|
32
|
+
id: string;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
type MailooMarketTagLocale = {
|
|
36
|
+
name?: string;
|
|
37
|
+
shortDescription?: string | null;
|
|
38
|
+
fullDescription?: string | null;
|
|
39
|
+
};
|
|
40
|
+
type MailooMarketTagInput = {
|
|
41
|
+
slug: string;
|
|
42
|
+
name: string;
|
|
43
|
+
parentTagId?: string | null;
|
|
44
|
+
useAsRoot?: boolean;
|
|
45
|
+
sortOrder?: number;
|
|
46
|
+
iconMediaId?: string | null;
|
|
47
|
+
shortDescription?: string | null;
|
|
48
|
+
fullDescription?: string | null;
|
|
49
|
+
locales?: Record<string, MailooMarketTagLocale> | null;
|
|
50
|
+
};
|
|
51
|
+
type MailooMarketTag = MailooMarketRecord & {
|
|
52
|
+
id: string;
|
|
53
|
+
slug: string;
|
|
54
|
+
name: string;
|
|
55
|
+
parentTagId?: string | null;
|
|
56
|
+
useAsRoot?: boolean;
|
|
57
|
+
sortOrder?: number;
|
|
58
|
+
iconMediaId?: string | null;
|
|
59
|
+
shortDescription?: string | null;
|
|
60
|
+
fullDescription?: string | null;
|
|
61
|
+
locales?: Record<string, MailooMarketTagLocale> | null;
|
|
62
|
+
};
|
|
63
|
+
type MailooMarketProductLocales = Record<string, {
|
|
64
|
+
name?: string;
|
|
65
|
+
attributes?: Record<string, unknown>;
|
|
66
|
+
}> | null;
|
|
67
|
+
type MailooMarketProductInput = {
|
|
68
|
+
typeIds: string[];
|
|
69
|
+
status?: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
|
|
70
|
+
attributes?: Record<string, unknown>;
|
|
71
|
+
locales?: MailooMarketProductLocales;
|
|
72
|
+
tagIds?: string[];
|
|
73
|
+
imageMediaIds?: string[];
|
|
74
|
+
previewMediaId?: string | null;
|
|
75
|
+
model3dMediaId?: string | null;
|
|
76
|
+
model3dUrl?: string | null;
|
|
77
|
+
defaultMeasurementUnitId?: string;
|
|
78
|
+
measurementUnitIds?: string[];
|
|
79
|
+
};
|
|
80
|
+
type MailooMarketVariantInput = {
|
|
81
|
+
sortOrder?: number;
|
|
82
|
+
attributes?: Record<string, unknown>;
|
|
83
|
+
locales?: MailooMarketProductLocales;
|
|
84
|
+
};
|
|
85
|
+
type MailooMarketTypeInput = {
|
|
86
|
+
key: string;
|
|
87
|
+
name: string;
|
|
88
|
+
locales?: Record<string, unknown> | null;
|
|
89
|
+
};
|
|
90
|
+
type MailooMarketAttributeInput = {
|
|
91
|
+
key: string;
|
|
92
|
+
name: string;
|
|
93
|
+
valueType: 'STRING' | 'NUMBER' | 'BOOLEAN' | 'ENUM' | 'SELECT' | 'MD_TEXT';
|
|
94
|
+
locales?: Record<string, unknown> | null;
|
|
95
|
+
isRequired?: boolean;
|
|
96
|
+
isVariantAxis?: boolean;
|
|
97
|
+
options?: string[] | null;
|
|
98
|
+
};
|
|
99
|
+
type MailooMarketPriceQuery = {
|
|
100
|
+
productId?: string;
|
|
101
|
+
variantId?: string | null;
|
|
102
|
+
kind?: string;
|
|
103
|
+
priceKindId?: string;
|
|
104
|
+
measurementUnitId?: string | null;
|
|
105
|
+
at?: string | null;
|
|
106
|
+
currency?: string;
|
|
107
|
+
};
|
|
108
|
+
type MailooMarketEffectivePriceQuery = MailooMarketPriceQuery & {
|
|
109
|
+
productId: string;
|
|
110
|
+
};
|
|
111
|
+
type MailooMarketLocaleQuery = {
|
|
112
|
+
locale?: string;
|
|
113
|
+
};
|
|
114
|
+
type MailooMarketOrderInput = {
|
|
115
|
+
customerEmail: string;
|
|
116
|
+
items: Array<{
|
|
117
|
+
productId: string;
|
|
118
|
+
quantity: string;
|
|
119
|
+
variantId?: string | null;
|
|
120
|
+
measurementUnitId?: string | null;
|
|
121
|
+
priceKindId?: string;
|
|
122
|
+
priceKindKey?: string;
|
|
123
|
+
}>;
|
|
124
|
+
note?: string;
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
};
|
|
127
|
+
type MailooMarketReadOptions = {
|
|
128
|
+
cache?: RequestInit['cache'];
|
|
129
|
+
revalidate?: number | false;
|
|
130
|
+
};
|
|
131
|
+
type MailooMarketClientOptions = MailooMarketReadOptions & {
|
|
132
|
+
fetch?: typeof globalThis.fetch;
|
|
133
|
+
/** Next wrapper rethrows framework control-flow errors. */ rethrow?: (error: unknown) => void;
|
|
134
|
+
};
|
|
135
|
+
type MailooMarketListProductsResult = MailooMarketResult<MailooMarketProduct[]>;
|
|
136
|
+
/** Legacy methods return the entire upstream envelope; new methods unwrap data. */
|
|
137
|
+
type MailooMarketSubmitOrderResult = MailooMarketResult<unknown>;
|
|
138
|
+
type MailooMarketDeleteVariantResult = MailooMarketResult<unknown>;
|
|
139
|
+
|
|
140
|
+
export { MAILOO_MARKET_INTEGRATION_PREFIX as M, type MailooMarketApiError as a, type MailooMarketAttributeInput as b, type MailooMarketClientOptions as c, type MailooMarketConfig as d, type MailooMarketDeleteVariantResult as e, type MailooMarketEffectivePriceQuery as f, type MailooMarketErrorBody as g, type MailooMarketListProductsResult as h, type MailooMarketLocaleQuery as i, type MailooMarketOrderInput as j, type MailooMarketPriceQuery as k, type MailooMarketProduct as l, type MailooMarketProductInput as m, type MailooMarketProductLocales as n, type MailooMarketReadOptions as o, type MailooMarketRecord as p, type MailooMarketResult as q, type MailooMarketSubmitOrderResult as r, type MailooMarketTag as s, type MailooMarketTagInput as t, type MailooMarketTagLocale as u, type MailooMarketTypeInput as v, type MailooMarketVariantInput as w };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** Framework-neutral server/job contracts. No API key belongs in browser code. */
|
|
2
|
+
declare const MAILOO_MARKET_INTEGRATION_PREFIX: "MAILOO_MARKET";
|
|
3
|
+
type MailooMarketConfig = {
|
|
4
|
+
apiBaseUrl: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
projectUid: string;
|
|
7
|
+
integrationId: string;
|
|
8
|
+
};
|
|
9
|
+
type MailooMarketRecord = Record<string, unknown>;
|
|
10
|
+
type MailooMarketErrorBody = null | boolean | number | string | MailooMarketErrorBody[] | {
|
|
11
|
+
[key: string]: MailooMarketErrorBody;
|
|
12
|
+
};
|
|
13
|
+
type MailooMarketApiError = {
|
|
14
|
+
code?: string | number;
|
|
15
|
+
message?: string;
|
|
16
|
+
details?: MailooMarketErrorBody;
|
|
17
|
+
};
|
|
18
|
+
type MailooMarketResult<T> = {
|
|
19
|
+
ok: true;
|
|
20
|
+
data: T;
|
|
21
|
+
status: number;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
status: number;
|
|
25
|
+
body?: MailooMarketErrorBody;
|
|
26
|
+
error?: MailooMarketApiError;
|
|
27
|
+
};
|
|
28
|
+
type MailooMarketProduct = MailooMarketRecord & {
|
|
29
|
+
id: string;
|
|
30
|
+
attributes?: Record<string, unknown>;
|
|
31
|
+
variants?: Array<{
|
|
32
|
+
id: string;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
type MailooMarketTagLocale = {
|
|
36
|
+
name?: string;
|
|
37
|
+
shortDescription?: string | null;
|
|
38
|
+
fullDescription?: string | null;
|
|
39
|
+
};
|
|
40
|
+
type MailooMarketTagInput = {
|
|
41
|
+
slug: string;
|
|
42
|
+
name: string;
|
|
43
|
+
parentTagId?: string | null;
|
|
44
|
+
useAsRoot?: boolean;
|
|
45
|
+
sortOrder?: number;
|
|
46
|
+
iconMediaId?: string | null;
|
|
47
|
+
shortDescription?: string | null;
|
|
48
|
+
fullDescription?: string | null;
|
|
49
|
+
locales?: Record<string, MailooMarketTagLocale> | null;
|
|
50
|
+
};
|
|
51
|
+
type MailooMarketTag = MailooMarketRecord & {
|
|
52
|
+
id: string;
|
|
53
|
+
slug: string;
|
|
54
|
+
name: string;
|
|
55
|
+
parentTagId?: string | null;
|
|
56
|
+
useAsRoot?: boolean;
|
|
57
|
+
sortOrder?: number;
|
|
58
|
+
iconMediaId?: string | null;
|
|
59
|
+
shortDescription?: string | null;
|
|
60
|
+
fullDescription?: string | null;
|
|
61
|
+
locales?: Record<string, MailooMarketTagLocale> | null;
|
|
62
|
+
};
|
|
63
|
+
type MailooMarketProductLocales = Record<string, {
|
|
64
|
+
name?: string;
|
|
65
|
+
attributes?: Record<string, unknown>;
|
|
66
|
+
}> | null;
|
|
67
|
+
type MailooMarketProductInput = {
|
|
68
|
+
typeIds: string[];
|
|
69
|
+
status?: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
|
|
70
|
+
attributes?: Record<string, unknown>;
|
|
71
|
+
locales?: MailooMarketProductLocales;
|
|
72
|
+
tagIds?: string[];
|
|
73
|
+
imageMediaIds?: string[];
|
|
74
|
+
previewMediaId?: string | null;
|
|
75
|
+
model3dMediaId?: string | null;
|
|
76
|
+
model3dUrl?: string | null;
|
|
77
|
+
defaultMeasurementUnitId?: string;
|
|
78
|
+
measurementUnitIds?: string[];
|
|
79
|
+
};
|
|
80
|
+
type MailooMarketVariantInput = {
|
|
81
|
+
sortOrder?: number;
|
|
82
|
+
attributes?: Record<string, unknown>;
|
|
83
|
+
locales?: MailooMarketProductLocales;
|
|
84
|
+
};
|
|
85
|
+
type MailooMarketTypeInput = {
|
|
86
|
+
key: string;
|
|
87
|
+
name: string;
|
|
88
|
+
locales?: Record<string, unknown> | null;
|
|
89
|
+
};
|
|
90
|
+
type MailooMarketAttributeInput = {
|
|
91
|
+
key: string;
|
|
92
|
+
name: string;
|
|
93
|
+
valueType: 'STRING' | 'NUMBER' | 'BOOLEAN' | 'ENUM' | 'SELECT' | 'MD_TEXT';
|
|
94
|
+
locales?: Record<string, unknown> | null;
|
|
95
|
+
isRequired?: boolean;
|
|
96
|
+
isVariantAxis?: boolean;
|
|
97
|
+
options?: string[] | null;
|
|
98
|
+
};
|
|
99
|
+
type MailooMarketPriceQuery = {
|
|
100
|
+
productId?: string;
|
|
101
|
+
variantId?: string | null;
|
|
102
|
+
kind?: string;
|
|
103
|
+
priceKindId?: string;
|
|
104
|
+
measurementUnitId?: string | null;
|
|
105
|
+
at?: string | null;
|
|
106
|
+
currency?: string;
|
|
107
|
+
};
|
|
108
|
+
type MailooMarketEffectivePriceQuery = MailooMarketPriceQuery & {
|
|
109
|
+
productId: string;
|
|
110
|
+
};
|
|
111
|
+
type MailooMarketLocaleQuery = {
|
|
112
|
+
locale?: string;
|
|
113
|
+
};
|
|
114
|
+
type MailooMarketOrderInput = {
|
|
115
|
+
customerEmail: string;
|
|
116
|
+
items: Array<{
|
|
117
|
+
productId: string;
|
|
118
|
+
quantity: string;
|
|
119
|
+
variantId?: string | null;
|
|
120
|
+
measurementUnitId?: string | null;
|
|
121
|
+
priceKindId?: string;
|
|
122
|
+
priceKindKey?: string;
|
|
123
|
+
}>;
|
|
124
|
+
note?: string;
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
};
|
|
127
|
+
type MailooMarketReadOptions = {
|
|
128
|
+
cache?: RequestInit['cache'];
|
|
129
|
+
revalidate?: number | false;
|
|
130
|
+
};
|
|
131
|
+
type MailooMarketClientOptions = MailooMarketReadOptions & {
|
|
132
|
+
fetch?: typeof globalThis.fetch;
|
|
133
|
+
/** Next wrapper rethrows framework control-flow errors. */ rethrow?: (error: unknown) => void;
|
|
134
|
+
};
|
|
135
|
+
type MailooMarketListProductsResult = MailooMarketResult<MailooMarketProduct[]>;
|
|
136
|
+
/** Legacy methods return the entire upstream envelope; new methods unwrap data. */
|
|
137
|
+
type MailooMarketSubmitOrderResult = MailooMarketResult<unknown>;
|
|
138
|
+
type MailooMarketDeleteVariantResult = MailooMarketResult<unknown>;
|
|
139
|
+
|
|
140
|
+
export { MAILOO_MARKET_INTEGRATION_PREFIX as M, type MailooMarketApiError as a, type MailooMarketAttributeInput as b, type MailooMarketClientOptions as c, type MailooMarketConfig as d, type MailooMarketDeleteVariantResult as e, type MailooMarketEffectivePriceQuery as f, type MailooMarketErrorBody as g, type MailooMarketListProductsResult as h, type MailooMarketLocaleQuery as i, type MailooMarketOrderInput as j, type MailooMarketPriceQuery as k, type MailooMarketProduct as l, type MailooMarketProductInput as m, type MailooMarketProductLocales as n, type MailooMarketReadOptions as o, type MailooMarketRecord as p, type MailooMarketResult as q, type MailooMarketSubmitOrderResult as r, type MailooMarketTag as s, type MailooMarketTagInput as t, type MailooMarketTagLocale as u, type MailooMarketTypeInput as v, type MailooMarketVariantInput as w };
|
package/dist/index.cjs
CHANGED
|
@@ -24,9 +24,7 @@ __export(src_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
|
-
// src/
|
|
28
|
-
var import_navigation = require("next/navigation");
|
|
29
|
-
var import_next_core = require("@mailoo/next-core");
|
|
27
|
+
// src/types.ts
|
|
30
28
|
var MAILOO_MARKET_INTEGRATION_PREFIX = "MAILOO_MARKET";
|
|
31
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
30
|
0 && (module.exports = {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types.ts"],"sourcesContent":["export {\n MAILOO_MARKET_INTEGRATION_PREFIX,\n type MailooMarketConfig,\n} from './types.js'\n","/** Framework-neutral server/job contracts. No API key belongs in browser code. */\nexport const MAILOO_MARKET_INTEGRATION_PREFIX = 'MAILOO_MARKET' as const\nexport type MailooMarketConfig = {\n apiBaseUrl: string\n apiKey: string\n projectUid: string\n integrationId: string\n}\nexport type MailooMarketRecord = Record<string, unknown>\nexport type MailooMarketErrorBody =\n | null\n | boolean\n | number\n | string\n | MailooMarketErrorBody[]\n | { [key: string]: MailooMarketErrorBody }\nexport type MailooMarketApiError = {\n code?: string | number\n message?: string\n details?: MailooMarketErrorBody\n}\nexport type MailooMarketResult<T> =\n | { ok: true; data: T; status: number }\n | {\n ok: false\n status: number\n body?: MailooMarketErrorBody\n error?: MailooMarketApiError\n }\nexport type MailooMarketProduct = MailooMarketRecord & {\n id: string\n attributes?: Record<string, unknown>\n variants?: Array<{ id: string }>\n}\nexport type MailooMarketTagLocale = {\n name?: string\n shortDescription?: string | null\n fullDescription?: string | null\n}\nexport type MailooMarketTagInput = {\n slug: string\n name: string\n parentTagId?: string | null\n useAsRoot?: boolean\n sortOrder?: number\n iconMediaId?: string | null\n shortDescription?: string | null\n fullDescription?: string | null\n locales?: Record<string, MailooMarketTagLocale> | null\n}\nexport type MailooMarketTag = MailooMarketRecord & {\n id: string\n slug: string\n name: string\n parentTagId?: string | null\n useAsRoot?: boolean\n sortOrder?: number\n iconMediaId?: string | null\n shortDescription?: string | null\n fullDescription?: string | null\n locales?: Record<string, MailooMarketTagLocale> | null\n}\nexport type MailooMarketProductLocales = Record<\n string,\n { name?: string; attributes?: Record<string, unknown> }\n> | null\nexport type MailooMarketProductInput = {\n typeIds: string[]\n status?: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED'\n attributes?: Record<string, unknown>\n locales?: MailooMarketProductLocales\n tagIds?: string[]\n imageMediaIds?: string[]\n previewMediaId?: string | null\n model3dMediaId?: string | null\n model3dUrl?: string | null\n defaultMeasurementUnitId?: string\n measurementUnitIds?: string[]\n}\nexport type MailooMarketVariantInput = {\n sortOrder?: number\n attributes?: Record<string, unknown>\n locales?: MailooMarketProductLocales\n}\nexport type MailooMarketTypeInput = {\n key: string\n name: string\n locales?: Record<string, unknown> | null\n}\nexport type MailooMarketAttributeInput = {\n key: string\n name: string\n valueType: 'STRING' | 'NUMBER' | 'BOOLEAN' | 'ENUM' | 'SELECT' | 'MD_TEXT'\n locales?: Record<string, unknown> | null\n isRequired?: boolean\n isVariantAxis?: boolean\n options?: string[] | null\n}\nexport type MailooMarketPriceQuery = {\n productId?: string\n variantId?: string | null\n kind?: string\n priceKindId?: string\n measurementUnitId?: string | null\n at?: string | null\n currency?: string\n}\nexport type MailooMarketEffectivePriceQuery = MailooMarketPriceQuery & {\n productId: string\n}\nexport type MailooMarketLocaleQuery = { locale?: string }\nexport type MailooMarketOrderInput = {\n customerEmail: string\n items: Array<{\n productId: string\n quantity: string\n variantId?: string | null\n measurementUnitId?: string | null\n priceKindId?: string\n priceKindKey?: string\n }>\n note?: string\n metadata?: Record<string, unknown>\n}\nexport type MailooMarketReadOptions = {\n cache?: RequestInit['cache']\n revalidate?: number | false\n}\nexport type MailooMarketClientOptions = MailooMarketReadOptions & {\n fetch?: typeof globalThis.fetch\n /** Next wrapper rethrows framework control-flow errors. */ rethrow?: (\n error: unknown\n ) => void\n}\nexport type MailooMarketListProductsResult = MailooMarketResult<\n MailooMarketProduct[]\n>\n/** Legacy methods return the entire upstream envelope; new methods unwrap data. */\nexport type MailooMarketSubmitOrderResult = MailooMarketResult<unknown>\nexport type MailooMarketDeleteVariantResult = MailooMarketResult<unknown>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,mCAAmC;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { MAILOO_MARKET_INTEGRATION_PREFIX, MailooMarketConfig } from './
|
|
2
|
-
import '@mailoo/next-core';
|
|
1
|
+
export { M as MAILOO_MARKET_INTEGRATION_PREFIX, d as MailooMarketConfig } from './index-CiEG0zwt.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { MAILOO_MARKET_INTEGRATION_PREFIX, MailooMarketConfig } from './
|
|
2
|
-
import '@mailoo/next-core';
|
|
1
|
+
export { M as MAILOO_MARKET_INTEGRATION_PREFIX, d as MailooMarketConfig } from './index-CiEG0zwt.js';
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,281 @@
|
|
|
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/node/index.ts
|
|
21
|
+
var node_exports = {};
|
|
22
|
+
__export(node_exports, {
|
|
23
|
+
MAILOO_MARKET_INTEGRATION_PREFIX: () => MAILOO_MARKET_INTEGRATION_PREFIX,
|
|
24
|
+
createMailooMarketClient: () => createMailooMarketClient,
|
|
25
|
+
createMailooMarketPublicClient: () => createMailooMarketPublicClient,
|
|
26
|
+
isMailooPriceKindCuid: () => isMailooPriceKindCuid,
|
|
27
|
+
mailooPriceKindEffectivePriceQuery: () => mailooPriceKindEffectivePriceQuery,
|
|
28
|
+
mailooPriceKindOrderLineFields: () => mailooPriceKindOrderLineFields
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(node_exports);
|
|
31
|
+
|
|
32
|
+
// src/error-body.ts
|
|
33
|
+
var secretField = /(?:authorization|cookie|password|passwd|secret|(?:api|private|signing|write|read).*key|token|databaseurl|connectionstring|dsn|cardnumber|cvv|cvc)/i;
|
|
34
|
+
function sanitizeMarketErrorBody(payload, secrets = []) {
|
|
35
|
+
const known = [
|
|
36
|
+
...new Set(
|
|
37
|
+
secrets.filter(Boolean).flatMap((s) => [s, encodeURIComponent(s)])
|
|
38
|
+
)
|
|
39
|
+
].sort((a, b) => b.length - a.length);
|
|
40
|
+
const text = (value) => {
|
|
41
|
+
for (const secret of known) value = value.split(secret).join("[REDACTED]");
|
|
42
|
+
return value.replace(/\b(?:Bearer|Basic)\s+[^\s,;"'<>]+/gi, "[REDACTED]").replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@]+@/gi, "$1[REDACTED]@").replace(
|
|
43
|
+
/\b((?:x-api-key|password|secret|access[_-]?token|refresh[_-]?token)\s*[:=]\s*)(?:"[^"\n]*"|'[^'\n]*'|[^\s,;]+)/gi,
|
|
44
|
+
"$1[REDACTED]"
|
|
45
|
+
).slice(0, 8192);
|
|
46
|
+
};
|
|
47
|
+
let budget = 500;
|
|
48
|
+
const visit = (value, depth) => {
|
|
49
|
+
if (--budget < 0 || depth > 8) return "[TRUNCATED]";
|
|
50
|
+
if (typeof value === "string") return text(value);
|
|
51
|
+
if (value === null || typeof value === "boolean") return value;
|
|
52
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
53
|
+
if (Array.isArray(value))
|
|
54
|
+
return value.slice(0, 100).map((v) => visit(v, depth + 1));
|
|
55
|
+
if (value && typeof value === "object")
|
|
56
|
+
return Object.fromEntries(
|
|
57
|
+
Object.entries(value).slice(0, 100).map(([key, val]) => [
|
|
58
|
+
text(key),
|
|
59
|
+
secretField.test(key.replace(/[^a-z0-9]/gi, "")) ? "[REDACTED]" : visit(val, depth + 1)
|
|
60
|
+
])
|
|
61
|
+
);
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
64
|
+
return visit(payload, 0);
|
|
65
|
+
}
|
|
66
|
+
function marketErrorFields(body) {
|
|
67
|
+
if (typeof body === "string") return { message: body };
|
|
68
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return void 0;
|
|
69
|
+
const source = body.error && typeof body.error === "object" && !Array.isArray(body.error) ? body.error : body;
|
|
70
|
+
const error = {};
|
|
71
|
+
if (typeof source.code === "string" || typeof source.code === "number")
|
|
72
|
+
error.code = source.code;
|
|
73
|
+
if (typeof source.message === "string") error.message = source.message;
|
|
74
|
+
else if (typeof body.error === "string") error.message = body.error;
|
|
75
|
+
if (source.details !== void 0) error.details = source.details;
|
|
76
|
+
else if (source.issues !== void 0) error.details = source.issues;
|
|
77
|
+
return Object.keys(error).length ? error : void 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/types.ts
|
|
81
|
+
var MAILOO_MARKET_INTEGRATION_PREFIX = "MAILOO_MARKET";
|
|
82
|
+
|
|
83
|
+
// src/price-kind.ts
|
|
84
|
+
function isMailooPriceKindCuid(value) {
|
|
85
|
+
const v = value.trim();
|
|
86
|
+
return v.length >= 20 && v.length <= 128 && /^[a-z0-9]+$/i.test(v);
|
|
87
|
+
}
|
|
88
|
+
function fields(value, key) {
|
|
89
|
+
const ref = value.trim();
|
|
90
|
+
return !ref ? {} : isMailooPriceKindCuid(ref) ? { priceKindId: ref } : { [key]: ref };
|
|
91
|
+
}
|
|
92
|
+
function mailooPriceKindEffectivePriceQuery(value) {
|
|
93
|
+
return fields(value, "kind");
|
|
94
|
+
}
|
|
95
|
+
function mailooPriceKindOrderLineFields(value) {
|
|
96
|
+
return fields(value, "priceKindKey");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/client.ts
|
|
100
|
+
var id = (value) => encodeURIComponent(value);
|
|
101
|
+
function baseUrl(base) {
|
|
102
|
+
const url = new URL(base);
|
|
103
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password)
|
|
104
|
+
throw new Error("Invalid Market API base URL");
|
|
105
|
+
return url.origin + url.pathname.replace(/\/+$/, "");
|
|
106
|
+
}
|
|
107
|
+
function createMailooMarketClient(config, options = {}) {
|
|
108
|
+
const root = () => `${baseUrl(config.apiBaseUrl)}/api/v1/market/${id(config.projectUid)}/integrations/${id(config.integrationId)}`;
|
|
109
|
+
const urlFor = (suffix, query, publicPath = false) => {
|
|
110
|
+
const url = new URL(
|
|
111
|
+
publicPath ? `${baseUrl(config.apiBaseUrl)}/api/v1/market${suffix}` : root() + suffix
|
|
112
|
+
);
|
|
113
|
+
for (const [key, value] of Object.entries(query ?? {}))
|
|
114
|
+
if (value !== void 0 && value !== null && value !== "")
|
|
115
|
+
url.searchParams.set(key, String(value));
|
|
116
|
+
return url.toString();
|
|
117
|
+
};
|
|
118
|
+
const send = async (suffix, method = "GET", body, query, read = {}, publicPath = false) => {
|
|
119
|
+
try {
|
|
120
|
+
const cache = read.cache ?? options.cache;
|
|
121
|
+
const init = {
|
|
122
|
+
method,
|
|
123
|
+
headers: {
|
|
124
|
+
Accept: "application/json",
|
|
125
|
+
"Content-Type": "application/json",
|
|
126
|
+
...!publicPath ? { "X-API-Key": config.apiKey } : {}
|
|
127
|
+
},
|
|
128
|
+
redirect: "error",
|
|
129
|
+
...method === "GET" && cache !== "no-store" ? {
|
|
130
|
+
...cache ? { cache } : {},
|
|
131
|
+
next: { revalidate: read.revalidate ?? options.revalidate ?? 60 }
|
|
132
|
+
} : { cache: "no-store" },
|
|
133
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
134
|
+
};
|
|
135
|
+
const response = await (options.fetch ?? globalThis.fetch)(
|
|
136
|
+
urlFor(suffix, query, publicPath),
|
|
137
|
+
init
|
|
138
|
+
);
|
|
139
|
+
let payload;
|
|
140
|
+
if (!response.ok && typeof response.text === "function") {
|
|
141
|
+
const text = await response.text().catch(() => "");
|
|
142
|
+
try {
|
|
143
|
+
payload = JSON.parse(text);
|
|
144
|
+
} catch {
|
|
145
|
+
payload = text || null;
|
|
146
|
+
}
|
|
147
|
+
} else payload = await response.json().catch(() => null);
|
|
148
|
+
return { ok: response.ok, status: response.status, payload };
|
|
149
|
+
} catch (error) {
|
|
150
|
+
options.rethrow?.(error);
|
|
151
|
+
return { ok: false, status: 500, payload: null };
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const request = async (suffix, method = "GET", body, query, read, shape = "record", publicPath = false) => {
|
|
155
|
+
const res = await send(suffix, method, body, query, read, publicPath);
|
|
156
|
+
if (!res.ok) {
|
|
157
|
+
if (res.payload === null) return { ok: false, status: res.status };
|
|
158
|
+
const body2 = sanitizeMarketErrorBody(res.payload, [
|
|
159
|
+
config.apiKey,
|
|
160
|
+
typeof query?.token === "string" ? query.token : ""
|
|
161
|
+
]);
|
|
162
|
+
const error = marketErrorFields(body2);
|
|
163
|
+
return {
|
|
164
|
+
ok: false,
|
|
165
|
+
status: res.status,
|
|
166
|
+
body: body2,
|
|
167
|
+
...error ? { error } : {}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const envelope = res.payload && typeof res.payload === "object" && !Array.isArray(res.payload) ? res.payload : null;
|
|
171
|
+
if (shape === "legacy")
|
|
172
|
+
return { ok: true, status: res.status, data: res.payload ?? {} };
|
|
173
|
+
const data = envelope?.data ?? (shape === "record-or-payload" && envelope && !("data" in envelope) && typeof envelope.success !== "boolean" ? envelope : void 0);
|
|
174
|
+
if (envelope?.success === false || (shape === "array" ? !Array.isArray(data) : !data || typeof data !== "object" || Array.isArray(data)))
|
|
175
|
+
return { ok: false, status: 500 };
|
|
176
|
+
return { ok: true, status: res.status, data };
|
|
177
|
+
};
|
|
178
|
+
const list = (suffix, query, read) => request(suffix, "GET", void 0, query, read, "array");
|
|
179
|
+
const get = (suffix, query, read) => request(suffix, "GET", void 0, query, read);
|
|
180
|
+
const write = (suffix, method, body) => request(suffix, method, body);
|
|
181
|
+
return {
|
|
182
|
+
listTypes: () => list("/types"),
|
|
183
|
+
listProducts: (query, read) => list("/products", query, read),
|
|
184
|
+
getProduct: (productId, query) => get(`/products/${id(productId)}`, query),
|
|
185
|
+
listProductVariants: (productId, query) => list(`/products/${id(productId)}/variants`, query),
|
|
186
|
+
getProductPriceRange: (productId, query) => get(`/products/${id(productId)}/price-range`, query),
|
|
187
|
+
listTags: (read) => list("/tags", void 0, read),
|
|
188
|
+
getTag: (tagId) => request(`/tags/${id(tagId)}`),
|
|
189
|
+
listPriceLists: () => list("/price-lists"),
|
|
190
|
+
getPriceList: (priceListId) => get(`/price-lists/${id(priceListId)}`),
|
|
191
|
+
getEffectivePrice: (query, read) => get("/effective-price", query, read),
|
|
192
|
+
effectivePriceRequestUrl: (query) => urlFor("/effective-price", query),
|
|
193
|
+
/** Explicit dev diagnostics only; redact the configured key if upstream echoes it. */
|
|
194
|
+
async inspectEffectivePrice(query) {
|
|
195
|
+
const res = await send("/effective-price", "GET", void 0, query, {
|
|
196
|
+
cache: "no-store"
|
|
197
|
+
});
|
|
198
|
+
const body = sanitizeMarketErrorBody(res.payload, [config.apiKey]);
|
|
199
|
+
return { status: res.status, body };
|
|
200
|
+
},
|
|
201
|
+
listSuppliers: () => list("/suppliers"),
|
|
202
|
+
listSupplierProducts: (supplierId) => list(`/suppliers/${id(supplierId)}/products`),
|
|
203
|
+
listSupplierPriceLists: (supplierId) => list(`/suppliers/${id(supplierId)}/price-lists`),
|
|
204
|
+
getSupplierPriceList: (supplierId, listId) => get(`/suppliers/${id(supplierId)}/price-lists/${id(listId)}`),
|
|
205
|
+
listUnits: () => list("/units"),
|
|
206
|
+
listPackagings: () => list("/packagings"),
|
|
207
|
+
listPackagingEquivalences: () => list("/packaging-equivalences"),
|
|
208
|
+
createTag: (body) => write("/tags", "POST", body),
|
|
209
|
+
updateTag: (tagId, body) => write(`/tags/${id(tagId)}`, "PATCH", body),
|
|
210
|
+
createType: (body) => write("/types", "POST", body),
|
|
211
|
+
updateType: (typeId, body) => write(`/types/${id(typeId)}`, "PATCH", body),
|
|
212
|
+
createTypeAttribute: (typeId, body) => write(`/types/${id(typeId)}/attributes`, "POST", body),
|
|
213
|
+
updateTypeAttribute: (typeId, attributeId, body) => write(
|
|
214
|
+
`/types/${id(typeId)}/attributes/${id(attributeId)}`,
|
|
215
|
+
"PATCH",
|
|
216
|
+
body
|
|
217
|
+
),
|
|
218
|
+
createProduct: (body) => write("/products", "POST", body),
|
|
219
|
+
updateProduct: (productId, body) => write(`/products/${id(productId)}`, "PATCH", body),
|
|
220
|
+
deleteProduct: (productId) => write(`/products/${id(productId)}`, "DELETE"),
|
|
221
|
+
createProductVariant: (productId, body) => write(`/products/${id(productId)}/variants`, "POST", body),
|
|
222
|
+
updateProductVariant: (productId, variantId, body) => write(
|
|
223
|
+
`/products/${id(productId)}/variants/${id(variantId)}`,
|
|
224
|
+
"PATCH",
|
|
225
|
+
body
|
|
226
|
+
),
|
|
227
|
+
/** Backward compatibility: retain the full envelope returned by these two existing methods. */
|
|
228
|
+
deleteProductVariant: (productId, variantId) => request(
|
|
229
|
+
`/products/${id(productId)}/variants/${id(variantId)}`,
|
|
230
|
+
"DELETE",
|
|
231
|
+
void 0,
|
|
232
|
+
void 0,
|
|
233
|
+
void 0,
|
|
234
|
+
"legacy"
|
|
235
|
+
),
|
|
236
|
+
submitOrder: (body) => request("/orders", "POST", body, void 0, void 0, "legacy"),
|
|
237
|
+
createOrder: (body) => write("/orders", "POST", body),
|
|
238
|
+
getPublicOrder: (orderId, token) => request(
|
|
239
|
+
`/public/orders/${id(orderId)}`,
|
|
240
|
+
"GET",
|
|
241
|
+
void 0,
|
|
242
|
+
{ token },
|
|
243
|
+
{ cache: "no-store" },
|
|
244
|
+
"record",
|
|
245
|
+
true
|
|
246
|
+
),
|
|
247
|
+
getOfferGenerator: (generatorId, query) => request(
|
|
248
|
+
`/offer-generators/${id(generatorId)}`,
|
|
249
|
+
"GET",
|
|
250
|
+
void 0,
|
|
251
|
+
query,
|
|
252
|
+
void 0,
|
|
253
|
+
"record-or-payload"
|
|
254
|
+
),
|
|
255
|
+
submitOfferGenerator: (generatorId, variables) => request(
|
|
256
|
+
`/offer-generators/${id(generatorId)}/submissions`,
|
|
257
|
+
"POST",
|
|
258
|
+
{ variables },
|
|
259
|
+
void 0,
|
|
260
|
+
void 0,
|
|
261
|
+
"record-or-payload"
|
|
262
|
+
)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function createMailooMarketPublicClient(config, options) {
|
|
266
|
+
const client = createMailooMarketClient(
|
|
267
|
+
{ ...config, apiKey: "", projectUid: "", integrationId: "" },
|
|
268
|
+
options
|
|
269
|
+
);
|
|
270
|
+
return { getPublicOrder: client.getPublicOrder };
|
|
271
|
+
}
|
|
272
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
273
|
+
0 && (module.exports = {
|
|
274
|
+
MAILOO_MARKET_INTEGRATION_PREFIX,
|
|
275
|
+
createMailooMarketClient,
|
|
276
|
+
createMailooMarketPublicClient,
|
|
277
|
+
isMailooPriceKindCuid,
|
|
278
|
+
mailooPriceKindEffectivePriceQuery,
|
|
279
|
+
mailooPriceKindOrderLineFields
|
|
280
|
+
});
|
|
281
|
+
//# sourceMappingURL=index.cjs.map
|