@edgebound/bigcommerce 0.0.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.
Files changed (45) hide show
  1. package/dist/bigcommerce.fetcher-D1TyK4y4.d.mts +90 -0
  2. package/dist/bigcommerce.fetcher-D1TyK4y4.d.ts +90 -0
  3. package/dist/chunk-7GBRYAQG.mjs +272 -0
  4. package/dist/chunk-7GBRYAQG.mjs.map +1 -0
  5. package/dist/chunk-CERZFSUE.mjs +20 -0
  6. package/dist/chunk-CERZFSUE.mjs.map +1 -0
  7. package/dist/companies.d.mts +2 -0
  8. package/dist/companies.d.ts +2 -0
  9. package/dist/companies.js +2 -0
  10. package/dist/companies.js.map +1 -0
  11. package/dist/companies.mjs +1 -0
  12. package/dist/companies.mjs.map +1 -0
  13. package/dist/currencies.d.mts +2 -0
  14. package/dist/currencies.d.ts +2 -0
  15. package/dist/currencies.js +2 -0
  16. package/dist/currencies.js.map +1 -0
  17. package/dist/currencies.mjs +1 -0
  18. package/dist/currencies.mjs.map +1 -0
  19. package/dist/customers.d.mts +65 -0
  20. package/dist/customers.d.ts +65 -0
  21. package/dist/customers.js +399 -0
  22. package/dist/customers.js.map +1 -0
  23. package/dist/customers.mjs +107 -0
  24. package/dist/customers.mjs.map +1 -0
  25. package/dist/index.d.mts +29 -0
  26. package/dist/index.d.ts +29 -0
  27. package/dist/index.js +304 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/index.mjs +37 -0
  30. package/dist/index.mjs.map +1 -0
  31. package/dist/orders.d.mts +416 -0
  32. package/dist/orders.d.ts +416 -0
  33. package/dist/orders.js +608 -0
  34. package/dist/orders.js.map +1 -0
  35. package/dist/orders.mjs +314 -0
  36. package/dist/orders.mjs.map +1 -0
  37. package/dist/products.d.mts +32 -0
  38. package/dist/products.d.ts +32 -0
  39. package/dist/products.js +409 -0
  40. package/dist/products.js.map +1 -0
  41. package/dist/products.mjs +119 -0
  42. package/dist/products.mjs.map +1 -0
  43. package/dist/validation.error-CHLpPYC_.d.mts +14 -0
  44. package/dist/validation.error-CHLpPYC_.d.ts +14 -0
  45. package/package.json +63 -0
@@ -0,0 +1,90 @@
1
+ import { Context, Effect } from 'effect';
2
+ import * as z from 'zod';
3
+ import * as effect_Cause from 'effect/Cause';
4
+ import * as effect_Types from 'effect/Types';
5
+
6
+ declare const BigCommerceUnprocessableEntityError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
7
+ readonly _tag: "BigCommerceUnprocessableEntityError";
8
+ } & Readonly<A>;
9
+ declare class BigCommerceUnprocessableEntityError extends BigCommerceUnprocessableEntityError_base<{
10
+ readonly errorDetails: unknown;
11
+ }> {
12
+ }
13
+ declare const BigCommerceUnauthorizedError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
14
+ readonly _tag: "BigCommerceUnauthorizedError";
15
+ } & Readonly<A>;
16
+ declare class BigCommerceUnauthorizedError extends BigCommerceUnauthorizedError_base {
17
+ }
18
+ declare const BigCommerceForbiddenError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
19
+ readonly _tag: "BigCommerceForbiddenError";
20
+ } & Readonly<A>;
21
+ declare class BigCommerceForbiddenError extends BigCommerceForbiddenError_base {
22
+ }
23
+ declare const BigCommerceNotFoundError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
24
+ readonly _tag: "BigCommerceNotFoundError";
25
+ } & Readonly<A>;
26
+ declare class BigCommerceNotFoundError extends BigCommerceNotFoundError_base {
27
+ }
28
+ declare const BigCommerceConflictError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
29
+ readonly _tag: "BigCommerceConflictError";
30
+ } & Readonly<A>;
31
+ declare class BigCommerceConflictError extends BigCommerceConflictError_base<{
32
+ readonly details: unknown;
33
+ }> {
34
+ }
35
+ declare const BigCommerceConnectionError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
36
+ readonly _tag: "BigCommerceConnectionError";
37
+ } & Readonly<A>;
38
+ declare class BigCommerceConnectionError extends BigCommerceConnectionError_base<{
39
+ readonly message: string;
40
+ readonly type: 'timeout' | 'internalError' | 'unknown';
41
+ }> {
42
+ }
43
+ declare const BigCommerceUnknownError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
44
+ readonly _tag: "BigCommerceUnknownError";
45
+ } & Readonly<A>;
46
+ declare class BigCommerceUnknownError extends BigCommerceUnknownError_base<{
47
+ cause: unknown;
48
+ }> {
49
+ }
50
+ declare const BigCommerceInvalidResponseError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
51
+ readonly _tag: "BigCommerceInvalidResponseError";
52
+ } & Readonly<A>;
53
+ declare class BigCommerceInvalidResponseError extends BigCommerceInvalidResponseError_base<{
54
+ cause: unknown;
55
+ }> {
56
+ }
57
+ declare const BigCommerceInvalidRequestError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
58
+ readonly _tag: "BigCommerceInvalidRequestError";
59
+ } & Readonly<A>;
60
+ declare class BigCommerceInvalidRequestError extends BigCommerceInvalidRequestError_base<{
61
+ readonly errorDetails: unknown;
62
+ }> {
63
+ }
64
+ declare const BigCommerceParseResponseError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
65
+ readonly _tag: "BigCommerceParseResponseError";
66
+ } & Readonly<A>;
67
+ declare class BigCommerceParseResponseError extends BigCommerceParseResponseError_base<{
68
+ readonly error: z.ZodError;
69
+ }> {
70
+ }
71
+ type SomeBigCommerceError = BigCommerceUnprocessableEntityError | BigCommerceUnauthorizedError | BigCommerceForbiddenError | BigCommerceNotFoundError | BigCommerceConflictError | BigCommerceConnectionError | BigCommerceUnknownError | BigCommerceInvalidResponseError | BigCommerceInvalidRequestError | BigCommerceParseResponseError;
72
+
73
+ type BigCommerceFetchMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
74
+ interface BigCommerceFetchParams<Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string>, Result extends z.ZodType> {
75
+ readonly body?: Body;
76
+ readonly query?: Query;
77
+ readonly method: BigCommerceFetchMethods;
78
+ readonly path: string;
79
+ readonly headers?: Record<string, string>;
80
+ readonly isB2B: boolean;
81
+ readonly version: 'v3' | 'v2';
82
+ readonly resultSchema: Result;
83
+ }
84
+ declare const BigCommerceFetcher_base: Context.TagClass<BigCommerceFetcher, "BigCommerceFetcher", {
85
+ readonly fetch: <Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string>, Result extends z.ZodType>(params: BigCommerceFetchParams<Body, Query, Result>) => Effect.Effect<z.output<Result>, SomeBigCommerceError>;
86
+ }>;
87
+ declare class BigCommerceFetcher extends BigCommerceFetcher_base {
88
+ }
89
+
90
+ export { BigCommerceFetcher as B, type SomeBigCommerceError as S, BigCommerceUnprocessableEntityError as a, BigCommerceUnauthorizedError as b, BigCommerceForbiddenError as c, BigCommerceNotFoundError as d, BigCommerceConflictError as e, BigCommerceConnectionError as f, BigCommerceUnknownError as g, BigCommerceInvalidResponseError as h, BigCommerceInvalidRequestError as i, BigCommerceParseResponseError as j, type BigCommerceFetchMethods as k, type BigCommerceFetchParams as l };
@@ -0,0 +1,90 @@
1
+ import { Context, Effect } from 'effect';
2
+ import * as z from 'zod';
3
+ import * as effect_Cause from 'effect/Cause';
4
+ import * as effect_Types from 'effect/Types';
5
+
6
+ declare const BigCommerceUnprocessableEntityError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
7
+ readonly _tag: "BigCommerceUnprocessableEntityError";
8
+ } & Readonly<A>;
9
+ declare class BigCommerceUnprocessableEntityError extends BigCommerceUnprocessableEntityError_base<{
10
+ readonly errorDetails: unknown;
11
+ }> {
12
+ }
13
+ declare const BigCommerceUnauthorizedError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
14
+ readonly _tag: "BigCommerceUnauthorizedError";
15
+ } & Readonly<A>;
16
+ declare class BigCommerceUnauthorizedError extends BigCommerceUnauthorizedError_base {
17
+ }
18
+ declare const BigCommerceForbiddenError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
19
+ readonly _tag: "BigCommerceForbiddenError";
20
+ } & Readonly<A>;
21
+ declare class BigCommerceForbiddenError extends BigCommerceForbiddenError_base {
22
+ }
23
+ declare const BigCommerceNotFoundError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
24
+ readonly _tag: "BigCommerceNotFoundError";
25
+ } & Readonly<A>;
26
+ declare class BigCommerceNotFoundError extends BigCommerceNotFoundError_base {
27
+ }
28
+ declare const BigCommerceConflictError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
29
+ readonly _tag: "BigCommerceConflictError";
30
+ } & Readonly<A>;
31
+ declare class BigCommerceConflictError extends BigCommerceConflictError_base<{
32
+ readonly details: unknown;
33
+ }> {
34
+ }
35
+ declare const BigCommerceConnectionError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
36
+ readonly _tag: "BigCommerceConnectionError";
37
+ } & Readonly<A>;
38
+ declare class BigCommerceConnectionError extends BigCommerceConnectionError_base<{
39
+ readonly message: string;
40
+ readonly type: 'timeout' | 'internalError' | 'unknown';
41
+ }> {
42
+ }
43
+ declare const BigCommerceUnknownError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
44
+ readonly _tag: "BigCommerceUnknownError";
45
+ } & Readonly<A>;
46
+ declare class BigCommerceUnknownError extends BigCommerceUnknownError_base<{
47
+ cause: unknown;
48
+ }> {
49
+ }
50
+ declare const BigCommerceInvalidResponseError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
51
+ readonly _tag: "BigCommerceInvalidResponseError";
52
+ } & Readonly<A>;
53
+ declare class BigCommerceInvalidResponseError extends BigCommerceInvalidResponseError_base<{
54
+ cause: unknown;
55
+ }> {
56
+ }
57
+ declare const BigCommerceInvalidRequestError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
58
+ readonly _tag: "BigCommerceInvalidRequestError";
59
+ } & Readonly<A>;
60
+ declare class BigCommerceInvalidRequestError extends BigCommerceInvalidRequestError_base<{
61
+ readonly errorDetails: unknown;
62
+ }> {
63
+ }
64
+ declare const BigCommerceParseResponseError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
65
+ readonly _tag: "BigCommerceParseResponseError";
66
+ } & Readonly<A>;
67
+ declare class BigCommerceParseResponseError extends BigCommerceParseResponseError_base<{
68
+ readonly error: z.ZodError;
69
+ }> {
70
+ }
71
+ type SomeBigCommerceError = BigCommerceUnprocessableEntityError | BigCommerceUnauthorizedError | BigCommerceForbiddenError | BigCommerceNotFoundError | BigCommerceConflictError | BigCommerceConnectionError | BigCommerceUnknownError | BigCommerceInvalidResponseError | BigCommerceInvalidRequestError | BigCommerceParseResponseError;
72
+
73
+ type BigCommerceFetchMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
74
+ interface BigCommerceFetchParams<Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string>, Result extends z.ZodType> {
75
+ readonly body?: Body;
76
+ readonly query?: Query;
77
+ readonly method: BigCommerceFetchMethods;
78
+ readonly path: string;
79
+ readonly headers?: Record<string, string>;
80
+ readonly isB2B: boolean;
81
+ readonly version: 'v3' | 'v2';
82
+ readonly resultSchema: Result;
83
+ }
84
+ declare const BigCommerceFetcher_base: Context.TagClass<BigCommerceFetcher, "BigCommerceFetcher", {
85
+ readonly fetch: <Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string>, Result extends z.ZodType>(params: BigCommerceFetchParams<Body, Query, Result>) => Effect.Effect<z.output<Result>, SomeBigCommerceError>;
86
+ }>;
87
+ declare class BigCommerceFetcher extends BigCommerceFetcher_base {
88
+ }
89
+
90
+ export { BigCommerceFetcher as B, type SomeBigCommerceError as S, BigCommerceUnprocessableEntityError as a, BigCommerceUnauthorizedError as b, BigCommerceForbiddenError as c, BigCommerceNotFoundError as d, BigCommerceConflictError as e, BigCommerceConnectionError as f, BigCommerceUnknownError as g, BigCommerceInvalidResponseError as h, BigCommerceInvalidRequestError as i, BigCommerceParseResponseError as j, type BigCommerceFetchMethods as k, type BigCommerceFetchParams as l };
@@ -0,0 +1,272 @@
1
+ // src/core/bigcommerce.error.ts
2
+ import { Data } from "effect";
3
+ var BigCommerceUnprocessableEntityError = class extends Data.TaggedError(
4
+ "BigCommerceUnprocessableEntityError"
5
+ ) {
6
+ };
7
+ var BigCommerceUnauthorizedError = class extends Data.TaggedError(
8
+ "BigCommerceUnauthorizedError"
9
+ ) {
10
+ };
11
+ var BigCommerceForbiddenError = class extends Data.TaggedError("BigCommerceForbiddenError") {
12
+ };
13
+ var BigCommerceNotFoundError = class extends Data.TaggedError("BigCommerceNotFoundError") {
14
+ };
15
+ var BigCommerceConflictError = class extends Data.TaggedError("BigCommerceConflictError") {
16
+ };
17
+ var BigCommerceConnectionError = class extends Data.TaggedError("BigCommerceConnectionError") {
18
+ };
19
+ var BigCommerceUnknownError = class extends Data.TaggedError("BigCommerceUnknownError") {
20
+ };
21
+ var BigCommerceInvalidResponseError = class extends Data.TaggedError(
22
+ "BigCommerceInvalidResponseError"
23
+ ) {
24
+ };
25
+ var BigCommerceInvalidRequestError = class extends Data.TaggedError(
26
+ "BigCommerceInvalidRequestError"
27
+ ) {
28
+ };
29
+ var BigCommerceParseResponseError = class extends Data.TaggedError(
30
+ "BigCommerceParseResponseError"
31
+ ) {
32
+ };
33
+
34
+ // src/core/bigcommerce.fetcher.ts
35
+ import { Context } from "effect";
36
+ var BigCommerceFetcher = class extends Context.Tag("BigCommerceFetcher")() {
37
+ };
38
+
39
+ // src/core/bigcommerce.fetcher.live.ts
40
+ import { Effect as Effect3, Layer as Layer2, Match } from "effect";
41
+
42
+ // src/constants.ts
43
+ import { Duration, Schedule } from "effect";
44
+ var DEFAULT_TIMEOUT_MS = 3e4;
45
+ var API_BASE_URLS = {
46
+ B2B: "https://api-b2b.bigcommerce.com/api",
47
+ REGULAR: "https://api.bigcommerce.com/stores"
48
+ };
49
+ var GET_ORDER_BATCH_SIZE = 250;
50
+ var UPDATE_INVENTORY_BATCH_SIZE = 2e3;
51
+ var UPDATE_INVENTORY_CONCURRENCY = 2;
52
+ var DEFAULT_RETRY_TIMES = 2;
53
+ var DEFAULT_RETRY_WAIT = 200;
54
+ var DEFAULT_RETRY_SCHEDULE = Schedule.exponential(Duration.millis(DEFAULT_RETRY_WAIT));
55
+ var RETRY_POLICY_WITH_BACKOFF = Schedule.exponential(
56
+ Duration.millis(DEFAULT_RETRY_WAIT),
57
+ 2
58
+ ).pipe(Schedule.intersect(Schedule.recurs(DEFAULT_RETRY_TIMES)));
59
+ var GET_CUSTOMERS_BATCH_SIZE = 100;
60
+
61
+ // src/core/config.ts
62
+ import { Config, Context as Context2, Data as Data2, Effect as Effect2, Layer } from "effect";
63
+ var NoBigCommerceConfigError = class extends Data2.TaggedError("NoBigCommerceConfigError") {
64
+ };
65
+ var BigCommerceConfig = class extends Context2.Tag("BigCommerceConfig")() {
66
+ };
67
+ var getBigCommerceConfig = (key) => {
68
+ return Config.nested(Config.string(key), "BIGCOMMERCE").pipe(
69
+ Effect2.mapError(() => new NoBigCommerceConfigError({ key }))
70
+ );
71
+ };
72
+ var getBigCommerceTimeout = () => {
73
+ return Config.nested(Config.number("TIMEOUT"), "BIGCOMMERCE").pipe(
74
+ Effect2.mapError(() => new NoBigCommerceConfigError({ key: "TIMEOUT" })),
75
+ // Default to 30 seconds if not configured
76
+ Effect2.orElse(() => Effect2.succeed(DEFAULT_TIMEOUT_MS))
77
+ );
78
+ };
79
+ var BigCommerceConfigLive = Layer.effect(
80
+ BigCommerceConfig,
81
+ Effect2.gen(function* () {
82
+ const [storeHash, clientId, clientSecret, accessToken, timeout] = yield* Effect2.all([
83
+ getBigCommerceConfig("STORE_HASH"),
84
+ getBigCommerceConfig("CLIENT_ID"),
85
+ getBigCommerceConfig("CLIENT_SECRET"),
86
+ getBigCommerceConfig("ACCESS_TOKEN"),
87
+ getBigCommerceTimeout()
88
+ ]);
89
+ return {
90
+ getStoreHash: Effect2.succeed(storeHash),
91
+ getClientId: Effect2.succeed(clientId),
92
+ getClientSecret: Effect2.succeed(clientSecret),
93
+ getAccessToken: Effect2.succeed(accessToken),
94
+ getTimeout: Effect2.succeed(timeout)
95
+ };
96
+ })
97
+ );
98
+ var BigCommerceConfigTest = Layer.succeed(BigCommerceConfig, {
99
+ getAccessToken: Effect2.succeed("test"),
100
+ getClientId: Effect2.succeed("test"),
101
+ getClientSecret: Effect2.succeed("test"),
102
+ getStoreHash: Effect2.succeed("test"),
103
+ getTimeout: Effect2.succeed(DEFAULT_TIMEOUT_MS)
104
+ });
105
+
106
+ // src/core/bigcommerce.fetcher.live.ts
107
+ var BigCommerceStatusCodes = {
108
+ UNAUTHORIZED: 401,
109
+ CONFLICT: 409,
110
+ FORBIDDEN: 403,
111
+ NOT_FOUND: 404,
112
+ UNPROCESSABLE_ENTITY: 422,
113
+ INTERNAL_SERVER_ERROR: 500,
114
+ BAD_GATEWAY: 502,
115
+ SERVICE_UNAVAILABLE: 503,
116
+ GATEWAY_TIMEOUT: 504,
117
+ INVALID_REQUEST: 400
118
+ };
119
+ var BigCommerceFetcherLive = Layer2.effect(
120
+ BigCommerceFetcher,
121
+ Effect3.gen(function* () {
122
+ const config = yield* BigCommerceConfig;
123
+ const storeHash = yield* config.getStoreHash;
124
+ const accessToken = yield* config.getAccessToken;
125
+ const timeout = yield* config.getTimeout;
126
+ return {
127
+ fetch: (params) => {
128
+ const base = getBase(params);
129
+ const headers = {
130
+ Accept: "application/json",
131
+ "Content-Type": "application/json",
132
+ "x-auth-token": accessToken
133
+ };
134
+ if (params.isB2B) {
135
+ headers["x-store-hash"] = storeHash;
136
+ }
137
+ const url = applyParams(base.replace("[storeHash]", storeHash), params.query);
138
+ return Effect3.tryPromise({
139
+ try: () => fetch(url, {
140
+ headers,
141
+ signal: AbortSignal.timeout(timeout),
142
+ method: params.method,
143
+ ...params.body && { body: JSON.stringify(params.body) }
144
+ }),
145
+ catch: (error) => {
146
+ if (error instanceof Error && error.name === "TimeoutError") {
147
+ return new BigCommerceConnectionError({
148
+ message: `Request timeout after ${timeout}ms`,
149
+ type: "timeout"
150
+ });
151
+ }
152
+ if (error instanceof Error && error.name === "AbortError") {
153
+ return new BigCommerceConnectionError({
154
+ message: `Request timeout after ${timeout}ms`,
155
+ type: "timeout"
156
+ });
157
+ }
158
+ return new BigCommerceUnknownError({ cause: error });
159
+ }
160
+ }).pipe(
161
+ Effect3.tapError(
162
+ (error) => Effect3.logError("Failed to fetch from BigCommerce API", error.cause)
163
+ ),
164
+ Effect3.flatMap((response) => transformResponse(response, params.resultSchema))
165
+ );
166
+ }
167
+ };
168
+ })
169
+ );
170
+ var applyParams = (url, params) => {
171
+ const base = new URL(url);
172
+ if (!params) {
173
+ return base;
174
+ }
175
+ for (const [key, value] of Object.entries(params)) {
176
+ base.searchParams.append(key, `${value}`);
177
+ }
178
+ return base;
179
+ };
180
+ var getBase = ({
181
+ isB2B,
182
+ path,
183
+ version
184
+ }) => {
185
+ if (isB2B) {
186
+ return `${API_BASE_URLS.B2B}/${version}/io/${path}`;
187
+ }
188
+ return `${API_BASE_URLS.REGULAR}/[storeHash]/${version}/${path}`;
189
+ };
190
+ function processSuccessResponse(response, schema) {
191
+ return Effect3.tryPromise({
192
+ try: () => response.json(),
193
+ catch: (error) => new BigCommerceInvalidResponseError({ cause: error })
194
+ }).pipe(
195
+ Effect3.tapError(
196
+ (error) => Effect3.logError("Error parsing response from BigCommerce API", error.cause)
197
+ ),
198
+ Effect3.tryMap({
199
+ try: (json) => schema.parse(json),
200
+ catch: (error) => new BigCommerceParseResponseError({ error })
201
+ })
202
+ );
203
+ }
204
+ var processErrorResponse = (response) => {
205
+ const code = response.status;
206
+ return Effect3.tryPromise({
207
+ try: () => response.json(),
208
+ catch: (error) => new BigCommerceInvalidResponseError({ cause: error })
209
+ }).pipe(
210
+ Effect3.tapError((error) => Effect3.logError("Error parsing error response", error.cause)),
211
+ Effect3.flatMap(
212
+ (errorDetails) => Effect3.fail(
213
+ Match.value(code).pipe(
214
+ Match.when(
215
+ BigCommerceStatusCodes.INVALID_REQUEST,
216
+ () => new BigCommerceInvalidRequestError({ errorDetails })
217
+ ),
218
+ Match.when(BigCommerceStatusCodes.UNAUTHORIZED, () => new BigCommerceUnauthorizedError()),
219
+ Match.when(BigCommerceStatusCodes.FORBIDDEN, () => new BigCommerceForbiddenError()),
220
+ Match.when(BigCommerceStatusCodes.NOT_FOUND, () => new BigCommerceNotFoundError()),
221
+ Match.when(
222
+ BigCommerceStatusCodes.CONFLICT,
223
+ () => new BigCommerceConflictError({ details: errorDetails })
224
+ ),
225
+ Match.when(
226
+ BigCommerceStatusCodes.UNPROCESSABLE_ENTITY,
227
+ () => new BigCommerceUnprocessableEntityError({ errorDetails })
228
+ ),
229
+ Match.when(
230
+ (code2) => code2 >= 500,
231
+ () => new BigCommerceConnectionError({
232
+ message: `Server error: ${code}`,
233
+ type: code === BigCommerceStatusCodes.INTERNAL_SERVER_ERROR ? "internalError" : code === BigCommerceStatusCodes.BAD_GATEWAY || code === BigCommerceStatusCodes.GATEWAY_TIMEOUT ? "timeout" : "internalError"
234
+ })
235
+ ),
236
+ Match.orElse(() => new BigCommerceUnknownError({ cause: errorDetails }))
237
+ )
238
+ )
239
+ )
240
+ );
241
+ };
242
+ var transformResponse = (response, schema) => {
243
+ if (response.ok) {
244
+ return processSuccessResponse(response, schema);
245
+ }
246
+ return processErrorResponse(response);
247
+ };
248
+
249
+ export {
250
+ BigCommerceUnprocessableEntityError,
251
+ BigCommerceUnauthorizedError,
252
+ BigCommerceForbiddenError,
253
+ BigCommerceNotFoundError,
254
+ BigCommerceConflictError,
255
+ BigCommerceConnectionError,
256
+ BigCommerceUnknownError,
257
+ BigCommerceInvalidResponseError,
258
+ BigCommerceInvalidRequestError,
259
+ BigCommerceParseResponseError,
260
+ BigCommerceFetcher,
261
+ GET_ORDER_BATCH_SIZE,
262
+ UPDATE_INVENTORY_BATCH_SIZE,
263
+ UPDATE_INVENTORY_CONCURRENCY,
264
+ RETRY_POLICY_WITH_BACKOFF,
265
+ GET_CUSTOMERS_BATCH_SIZE,
266
+ NoBigCommerceConfigError,
267
+ BigCommerceConfig,
268
+ BigCommerceConfigLive,
269
+ BigCommerceConfigTest,
270
+ BigCommerceFetcherLive
271
+ };
272
+ //# sourceMappingURL=chunk-7GBRYAQG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/bigcommerce.error.ts","../src/core/bigcommerce.fetcher.ts","../src/core/bigcommerce.fetcher.live.ts","../src/constants.ts","../src/core/config.ts"],"sourcesContent":["import { Data } from 'effect';\nimport * as z from 'zod';\nexport class BigCommerceUnprocessableEntityError extends Data.TaggedError(\n 'BigCommerceUnprocessableEntityError',\n)<{\n readonly errorDetails: unknown;\n}> {}\n\nexport class BigCommerceUnauthorizedError extends Data.TaggedError(\n 'BigCommerceUnauthorizedError',\n) {}\n\nexport class BigCommerceForbiddenError extends Data.TaggedError('BigCommerceForbiddenError') {}\n\nexport class BigCommerceNotFoundError extends Data.TaggedError('BigCommerceNotFoundError') {}\n\nexport class BigCommerceConflictError extends Data.TaggedError('BigCommerceConflictError')<{\n readonly details: unknown;\n}> {}\n\nexport class BigCommerceConnectionError extends Data.TaggedError('BigCommerceConnectionError')<{\n readonly message: string;\n readonly type: 'timeout' | 'internalError' | 'unknown';\n}> {}\n\nexport class BigCommerceUnknownError extends Data.TaggedError('BigCommerceUnknownError')<{\n cause: unknown;\n}> {}\n\nexport class BigCommerceInvalidResponseError extends Data.TaggedError(\n 'BigCommerceInvalidResponseError',\n)<{\n cause: unknown;\n}> {}\n\nexport class BigCommerceInvalidRequestError extends Data.TaggedError(\n 'BigCommerceInvalidRequestError',\n)<{\n readonly errorDetails: unknown;\n}> {}\n\nexport class BigCommerceParseResponseError extends Data.TaggedError(\n 'BigCommerceParseResponseError',\n)<{\n readonly error: z.ZodError;\n}> {}\n\nexport type SomeBigCommerceError =\n | BigCommerceUnprocessableEntityError\n | BigCommerceUnauthorizedError\n | BigCommerceForbiddenError\n | BigCommerceNotFoundError\n | BigCommerceConflictError\n | BigCommerceConnectionError\n | BigCommerceUnknownError\n | BigCommerceInvalidResponseError\n | BigCommerceInvalidRequestError\n | BigCommerceParseResponseError;\n","import { Context, Effect } from 'effect';\nimport * as z from 'zod';\nimport { type SomeBigCommerceError } from './bigcommerce.error';\nexport type BigCommerceFetchMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';\nexport interface BigCommerceFetchParams<\n // Always send json for now, maybe later send a Blob\n Body extends Record<string, unknown> | Array<Record<string, unknown>>,\n Query extends Record<string, string>,\n Result extends z.ZodType,\n> {\n readonly body?: Body;\n readonly query?: Query;\n readonly method: BigCommerceFetchMethods;\n readonly path: string;\n readonly headers?: Record<string, string>;\n readonly isB2B: boolean;\n readonly version: 'v3' | 'v2';\n readonly resultSchema: Result;\n}\n\nexport class BigCommerceFetcher extends Context.Tag('BigCommerceFetcher')<\n BigCommerceFetcher,\n {\n readonly fetch: <\n Body extends Record<string, unknown> | Array<Record<string, unknown>>,\n Query extends Record<string, string>,\n Result extends z.ZodType,\n >(\n params: BigCommerceFetchParams<Body, Query, Result>,\n ) => Effect.Effect<z.output<Result>, SomeBigCommerceError>;\n }\n>() {}\n","import { Effect, Layer, Match } from 'effect';\nimport * as z from 'zod';\nimport { API_BASE_URLS } from '../constants';\nimport {\n BigCommerceConflictError,\n BigCommerceConnectionError,\n BigCommerceForbiddenError,\n BigCommerceInvalidRequestError,\n BigCommerceInvalidResponseError,\n BigCommerceNotFoundError,\n BigCommerceParseResponseError,\n BigCommerceUnauthorizedError,\n BigCommerceUnknownError,\n BigCommerceUnprocessableEntityError,\n type SomeBigCommerceError,\n} from './bigcommerce.error';\nimport { BigCommerceFetcher } from './bigcommerce.fetcher';\nimport { BigCommerceConfig } from './config';\n\nconst BigCommerceStatusCodes = {\n UNAUTHORIZED: 401,\n CONFLICT: 409,\n FORBIDDEN: 403,\n NOT_FOUND: 404,\n UNPROCESSABLE_ENTITY: 422,\n INTERNAL_SERVER_ERROR: 500,\n BAD_GATEWAY: 502,\n SERVICE_UNAVAILABLE: 503,\n GATEWAY_TIMEOUT: 504,\n INVALID_REQUEST: 400,\n} as const;\n\nexport const BigCommerceFetcherLive = Layer.effect(\n BigCommerceFetcher,\n Effect.gen(function* () {\n const config = yield* BigCommerceConfig;\n const storeHash = yield* config.getStoreHash;\n const accessToken = yield* config.getAccessToken;\n const timeout = yield* config.getTimeout;\n return {\n fetch: (params) => {\n const base = getBase(params);\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'x-auth-token': accessToken,\n };\n\n if (params.isB2B) {\n headers['x-store-hash'] = storeHash;\n }\n const url = applyParams(base.replace('[storeHash]', storeHash), params.query);\n\n return Effect.tryPromise({\n try: () =>\n fetch(url, {\n headers,\n signal: AbortSignal.timeout(timeout),\n method: params.method,\n ...(params.body && { body: JSON.stringify(params.body) }),\n }),\n catch: (error) => {\n if (error instanceof Error && error.name === 'TimeoutError') {\n return new BigCommerceConnectionError({\n message: `Request timeout after ${timeout}ms`,\n type: 'timeout',\n });\n }\n if (error instanceof Error && error.name === 'AbortError') {\n return new BigCommerceConnectionError({\n message: `Request timeout after ${timeout}ms`,\n type: 'timeout',\n });\n }\n return new BigCommerceUnknownError({ cause: error });\n },\n }).pipe(\n Effect.tapError((error) =>\n Effect.logError('Failed to fetch from BigCommerce API', error.cause),\n ),\n Effect.flatMap((response) => transformResponse(response, params.resultSchema)),\n );\n },\n };\n }),\n);\nconst applyParams = (url: string, params?: Record<string, string | number>): URL => {\n const base = new URL(url);\n if (!params) {\n return base;\n }\n for (const [key, value] of Object.entries(params)) {\n base.searchParams.append(key, `${value}`);\n }\n return base;\n};\n\nconst getBase = ({\n isB2B,\n path,\n version,\n}: {\n isB2B: boolean;\n path: string;\n version: 'v3' | 'v2';\n}): string => {\n if (isB2B) {\n return `${API_BASE_URLS.B2B}/${version}/io/${path}`;\n }\n return `${API_BASE_URLS.REGULAR}/[storeHash]/${version}/${path}`;\n};\nfunction processSuccessResponse<Schema extends z.ZodTypeAny>(response: Response, schema: Schema) {\n return Effect.tryPromise({\n try: () => response.json(),\n catch: (error) => new BigCommerceInvalidResponseError({ cause: error }),\n }).pipe(\n Effect.tapError((error) =>\n Effect.logError('Error parsing response from BigCommerce API', error.cause),\n ),\n Effect.tryMap({\n try: (json) => schema.parse(json),\n catch: (error) => new BigCommerceParseResponseError({ error: error as z.ZodError }),\n }),\n );\n}\nconst processErrorResponse = (response: Response) => {\n const code = response.status;\n return Effect.tryPromise({\n try: () => response.json(),\n catch: (error) => new BigCommerceInvalidResponseError({ cause: error }),\n }).pipe(\n Effect.tapError((error) => Effect.logError('Error parsing error response', error.cause)),\n Effect.flatMap((errorDetails) =>\n Effect.fail(\n Match.value(code).pipe(\n Match.when(\n BigCommerceStatusCodes.INVALID_REQUEST,\n () => new BigCommerceInvalidRequestError({ errorDetails }),\n ),\n Match.when(BigCommerceStatusCodes.UNAUTHORIZED, () => new BigCommerceUnauthorizedError()),\n Match.when(BigCommerceStatusCodes.FORBIDDEN, () => new BigCommerceForbiddenError()),\n Match.when(BigCommerceStatusCodes.NOT_FOUND, () => new BigCommerceNotFoundError()),\n Match.when(\n BigCommerceStatusCodes.CONFLICT,\n () => new BigCommerceConflictError({ details: errorDetails }),\n ),\n Match.when(\n BigCommerceStatusCodes.UNPROCESSABLE_ENTITY,\n () => new BigCommerceUnprocessableEntityError({ errorDetails }),\n ),\n Match.when(\n (code) => code >= 500,\n () =>\n new BigCommerceConnectionError({\n message: `Server error: ${code}`,\n type:\n code === BigCommerceStatusCodes.INTERNAL_SERVER_ERROR\n ? 'internalError'\n : code === BigCommerceStatusCodes.BAD_GATEWAY ||\n code === BigCommerceStatusCodes.GATEWAY_TIMEOUT\n ? 'timeout'\n : 'internalError',\n }),\n ),\n Match.orElse(() => new BigCommerceUnknownError({ cause: errorDetails })),\n ),\n ),\n ),\n );\n};\n\nconst transformResponse = <Schema extends z.ZodTypeAny>(\n response: Response,\n schema: Schema,\n): Effect.Effect<z.output<Schema>, SomeBigCommerceError> => {\n if (response.ok) {\n return processSuccessResponse(response, schema);\n }\n return processErrorResponse(response);\n};\n\n// type PendingErrors = Exclude<\n// SomeBigCommerceError,\n// Effect.Effect.Error<ReturnType<typeof processErrorResponse>> | BigCommerceParseResponseError\n// >;\n","import { Duration, Schedule } from 'effect';\n\nexport const DEFAULT_TIMEOUT_MS = 30000;\nexport const API_BASE_URLS = {\n B2B: 'https://api-b2b.bigcommerce.com/api',\n REGULAR: 'https://api.bigcommerce.com/stores',\n} as const;\nexport const GET_ORDER_BATCH_SIZE = 250;\nexport const UPDATE_PRODUCT_BATCH_SIZE = 5;\nexport const UPDATE_INVENTORY_BATCH_SIZE = 2000;\nexport const UPDATE_INVENTORY_CONCURRENCY = 2;\nexport const DEFAULT_RETRY_TIMES = 2;\nexport const DEFAULT_RETRY_WAIT = 200;\nexport const DEFAULT_RETRY_SCHEDULE = Schedule.exponential(Duration.millis(DEFAULT_RETRY_WAIT));\nexport const RETRY_POLICY_WITH_BACKOFF = Schedule.exponential(\n Duration.millis(DEFAULT_RETRY_WAIT),\n 2,\n).pipe(Schedule.intersect(Schedule.recurs(DEFAULT_RETRY_TIMES)));\nexport const GET_CUSTOMERS_BATCH_SIZE = 100;\n","import { Config, Context, Data, Effect, Layer } from 'effect';\nimport { DEFAULT_TIMEOUT_MS } from '../constants';\n\n// Define a custom error type using Data.TaggedError\nexport class NoBigCommerceConfigError extends Data.TaggedError('NoBigCommerceConfigError')<{\n readonly key: string;\n}> {}\n\nexport class BigCommerceConfig extends Context.Tag('BigCommerceConfig')<\n BigCommerceConfig,\n {\n readonly getStoreHash: Effect.Effect<string, NoBigCommerceConfigError, string>;\n readonly getClientId: Effect.Effect<string, NoBigCommerceConfigError, string>;\n readonly getClientSecret: Effect.Effect<string, NoBigCommerceConfigError, string>;\n readonly getAccessToken: Effect.Effect<string, NoBigCommerceConfigError, string>;\n readonly getTimeout: Effect.Effect<number, NoBigCommerceConfigError, string>;\n }\n>() {}\n\nconst getBigCommerceConfig = (key: string) => {\n return Config.nested(Config.string(key), 'BIGCOMMERCE').pipe(\n Effect.mapError(() => new NoBigCommerceConfigError({ key })),\n );\n};\n\nconst getBigCommerceTimeout = () => {\n return Config.nested(Config.number('TIMEOUT'), 'BIGCOMMERCE').pipe(\n Effect.mapError(() => new NoBigCommerceConfigError({ key: 'TIMEOUT' })),\n // Default to 30 seconds if not configured\n Effect.orElse(() => Effect.succeed(DEFAULT_TIMEOUT_MS)),\n );\n};\n\nexport const BigCommerceConfigLive = Layer.effect(\n BigCommerceConfig,\n Effect.gen(function* () {\n const [storeHash, clientId, clientSecret, accessToken, timeout] = yield* Effect.all([\n getBigCommerceConfig('STORE_HASH'),\n getBigCommerceConfig('CLIENT_ID'),\n getBigCommerceConfig('CLIENT_SECRET'),\n getBigCommerceConfig('ACCESS_TOKEN'),\n getBigCommerceTimeout(),\n ]);\n\n return {\n getStoreHash: Effect.succeed(storeHash),\n getClientId: Effect.succeed(clientId),\n getClientSecret: Effect.succeed(clientSecret),\n getAccessToken: Effect.succeed(accessToken),\n getTimeout: Effect.succeed(timeout),\n };\n }),\n);\n\nexport const BigCommerceConfigTest = Layer.succeed(BigCommerceConfig, {\n getAccessToken: Effect.succeed('test'),\n getClientId: Effect.succeed('test'),\n getClientSecret: Effect.succeed('test'),\n getStoreHash: Effect.succeed('test'),\n getTimeout: Effect.succeed(DEFAULT_TIMEOUT_MS),\n});\n"],"mappings":";AAAA,SAAS,YAAY;AAEd,IAAM,sCAAN,cAAkD,KAAK;AAAA,EAC5D;AACF,EAEG;AAAC;AAEG,IAAM,+BAAN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AAa,CAAC,CAAC;AAAA,QACzE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAM,oBAAoB,CACxB,UACA,WAC0D;AAC1D,MAAI,SAAS,IAAI;AACf,WAAO,uBAAuB,UAAU,MAAM;AAAA,EAChD;AACA,SAAO,qBAAqB,QAAQ;AACtC;","names":["Effect","Layer","Context","Data","Effect","Data","Context","Effect","Layer","Effect","code"]}
@@ -0,0 +1,20 @@
1
+ // src/validation/index.ts
2
+ import { Effect } from "effect";
3
+
4
+ // src/validation/validation.error.ts
5
+ import { Data } from "effect";
6
+ var InputValidationError = class extends Data.TaggedError("InputValidationError") {
7
+ };
8
+
9
+ // src/validation/index.ts
10
+ var validateInput = (schema, data) => {
11
+ return Effect.try({
12
+ try: () => schema.parse(data),
13
+ catch: (error) => new InputValidationError({ input: data, error })
14
+ });
15
+ };
16
+
17
+ export {
18
+ validateInput
19
+ };
20
+ //# sourceMappingURL=chunk-CERZFSUE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/validation/index.ts","../src/validation/validation.error.ts"],"sourcesContent":["import { Effect } from 'effect';\nimport * as z from 'zod';\nimport { InputValidationError } from './validation.error';\nexport const validateInput = <Schema extends z.ZodType>(schema: Schema, data: z.input<Schema>) => {\n return Effect.try({\n try: () => schema.parse(data),\n catch: (error) => new InputValidationError({ input: data, error: error as z.ZodError }),\n });\n};\n","import { Data } from 'effect';\nimport * as z from 'zod';\nexport class InputValidationError extends Data.TaggedError('InputValidationError')<{\n input: unknown;\n error: z.ZodError;\n}> {}\n"],"mappings":";AAAA,SAAS,cAAc;;;ACAvB,SAAS,YAAY;AAEd,IAAM,uBAAN,cAAmC,KAAK,YAAY,sBAAsB,EAG9E;AAAC;;;ADFG,IAAM,gBAAgB,CAA2B,QAAgB,SAA0B;AAChG,SAAO,OAAO,IAAI;AAAA,IAChB,KAAK,MAAM,OAAO,MAAM,IAAI;AAAA,IAC5B,OAAO,CAAC,UAAU,IAAI,qBAAqB,EAAE,OAAO,MAAM,MAA2B,CAAC;AAAA,EACxF,CAAC;AACH;","names":[]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=companies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=companies.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=currencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=currencies.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,65 @@
1
+ import { I as InputValidationError } from './validation.error-CHLpPYC_.mjs';
2
+ import { S as SomeBigCommerceError, B as BigCommerceFetcher } from './bigcommerce.fetcher-D1TyK4y4.mjs';
3
+ import { Effect } from 'effect';
4
+ import * as z from 'zod';
5
+ import 'effect/Cause';
6
+ import 'effect/Types';
7
+
8
+ declare const FindCustomersCriteriaSchema: z.ZodObject<{
9
+ 'id:in': z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodInt>, z.ZodTransform<string, number[]>>>;
10
+ page: z.ZodOptional<z.ZodInt>;
11
+ limit: z.ZodOptional<z.ZodInt>;
12
+ 'company:in': z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>>;
13
+ 'customer_group_id:in': z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodInt>, z.ZodTransform<string, number[]>>>;
14
+ }, z.core.$strip>;
15
+ type FindCustomersCriteriaInput = z.input<typeof FindCustomersCriteriaSchema>;
16
+
17
+ declare const findCustomers: (criteria?: FindCustomersCriteriaInput) => Effect.Effect<{
18
+ data: {
19
+ email: string;
20
+ first_name: string;
21
+ last_name: string;
22
+ phone: string;
23
+ customer_group_id: number;
24
+ id: number;
25
+ channel_ids: number[];
26
+ company?: string | undefined;
27
+ }[];
28
+ meta: {
29
+ pagination: {
30
+ total: number;
31
+ count: number;
32
+ per_page: number;
33
+ current_page: number;
34
+ total_pages: number;
35
+ links: {
36
+ current: string;
37
+ previous?: string | null | undefined;
38
+ next?: string | null | undefined;
39
+ };
40
+ };
41
+ };
42
+ }, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
43
+ declare const getAllCustomersBy: (criteria: Omit<FindCustomersCriteriaInput, "page" | "limit">) => Effect.Effect<{
44
+ email: string;
45
+ first_name: string;
46
+ last_name: string;
47
+ phone: string;
48
+ customer_group_id: number;
49
+ id: number;
50
+ channel_ids: number[];
51
+ company?: string | undefined;
52
+ }[], SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
53
+
54
+ declare const getCustomer: (customerId: number) => Effect.Effect<{
55
+ email: string;
56
+ first_name: string;
57
+ last_name: string;
58
+ phone: string;
59
+ customer_group_id: number;
60
+ id: number;
61
+ channel_ids: number[];
62
+ company?: string | undefined;
63
+ } | undefined, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
64
+
65
+ export { findCustomers, getAllCustomersBy, getCustomer };