@edgebound/bigcommerce 0.3.1 → 0.3.2
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/{chunk-PAXNZ36X.mjs → chunk-V2WZ3SDN.mjs} +10 -3
- package/dist/chunk-V2WZ3SDN.mjs.map +1 -0
- package/dist/companies.d.mts +115 -1
- package/dist/companies.d.ts +115 -1
- package/dist/companies.js +125 -13
- package/dist/companies.js.map +1 -1
- package/dist/companies.mjs +111 -12
- package/dist/companies.mjs.map +1 -1
- package/dist/customers.d.mts +79 -1
- package/dist/customers.d.ts +79 -1
- package/dist/customers.js +143 -45
- package/dist/customers.js.map +1 -1
- package/dist/customers.mjs +131 -44
- package/dist/customers.mjs.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/orders.js +9 -2
- package/dist/orders.js.map +1 -1
- package/dist/orders.mjs +1 -1
- package/dist/payments.js +9 -2
- package/dist/payments.js.map +1 -1
- package/dist/payments.mjs +1 -1
- package/dist/priceLists.js +9 -2
- package/dist/priceLists.js.map +1 -1
- package/dist/priceLists.mjs +1 -1
- package/dist/products.js +9 -2
- package/dist/products.js.map +1 -1
- package/dist/products.mjs +1 -1
- package/dist/salesStaff.js +9 -2
- package/dist/salesStaff.js.map +1 -1
- package/dist/salesStaff.mjs +1 -1
- package/dist/webhooks.d.mts +6 -4
- package/dist/webhooks.d.ts +6 -4
- package/dist/webhooks.js +5 -3
- package/dist/webhooks.js.map +1 -1
- package/dist/webhooks.mjs +5 -3
- package/dist/webhooks.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-PAXNZ36X.mjs.map +0 -1
|
@@ -244,9 +244,16 @@ var getBase = ({
|
|
|
244
244
|
}
|
|
245
245
|
return `${DEFAULTS.bigcommerceUrls.regular}/[storeHash]/${version}/${path}`;
|
|
246
246
|
};
|
|
247
|
+
async function safeJson(response) {
|
|
248
|
+
const text = await response.text();
|
|
249
|
+
if (!text || text.trim() === "") {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
return JSON.parse(text);
|
|
253
|
+
}
|
|
247
254
|
function processSuccessResponse(response, schema) {
|
|
248
255
|
return Effect3.tryPromise({
|
|
249
|
-
try: () => response
|
|
256
|
+
try: () => safeJson(response),
|
|
250
257
|
catch: (error) => new BigCommerceInvalidResponseError({ cause: error })
|
|
251
258
|
}).pipe(
|
|
252
259
|
Effect3.tapError(
|
|
@@ -261,7 +268,7 @@ function processSuccessResponse(response, schema) {
|
|
|
261
268
|
var processErrorResponse = (response) => {
|
|
262
269
|
const code = response.status;
|
|
263
270
|
return Effect3.tryPromise({
|
|
264
|
-
try: () => response
|
|
271
|
+
try: () => safeJson(response),
|
|
265
272
|
catch: (error) => new BigCommerceInvalidResponseError({ cause: error })
|
|
266
273
|
}).pipe(
|
|
267
274
|
Effect3.tapError((error) => Effect3.logError("Error parsing error response", error.cause)),
|
|
@@ -323,4 +330,4 @@ export {
|
|
|
323
330
|
validateBigCommerceConfig,
|
|
324
331
|
BigCommerceFetcherLive
|
|
325
332
|
};
|
|
326
|
-
//# sourceMappingURL=chunk-
|
|
333
|
+
//# sourceMappingURL=chunk-V2WZ3SDN.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> | 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> | 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 { DEFAULTS } 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, type NoBigCommerceConfigError } from './config';\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.Layer<\n BigCommerceFetcher,\n NoBigCommerceConfigError,\n BigCommerceConfig\n> = 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\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> | string): URL => {\n const base = new URL(url);\n if (!params) {\n return base;\n }\n if (typeof params === 'string') {\n base.search = params;\n } else {\n for (const [key, value] of Object.entries(params)) {\n base.searchParams.append(key, `${value}`);\n }\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 `${DEFAULTS.bigcommerceUrls.b2b}/${version}/io/${path}`;\n }\n return `${DEFAULTS.bigcommerceUrls.regular}/[storeHash]/${version}/${path}`;\n};\n\nasync function safeJson<T>(response: Response): Promise<T | null> {\n const text = await response.text();\n\n if (!text || text.trim() === '') {\n return null;\n }\n\n return JSON.parse(text) as T;\n}\n\nfunction processSuccessResponse<Schema extends z.ZodTypeAny>(response: Response, schema: Schema) {\n return Effect.tryPromise({\n try: () => safeJson(response),\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: () => safeJson(response),\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.ZodType>(\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 DEFAULTS = {\n retry: {\n policy: Schedule.exponential(Duration.millis(200), 2).pipe(\n Schedule.intersect(Schedule.recurs(3)),\n ),\n },\n timeout: {\n ms: 30000,\n },\n bigcommerceUrls: {\n b2b: 'https://api-b2b.bigcommerce.com/api',\n regular: 'https://api.bigcommerce.com/stores',\n },\n customers: {\n getBatchSize: 250,\n },\n salesStaff: {\n getBatchSize: 250,\n },\n companies: {\n salesStaffAssignments: {\n assignBatchSize: 10,\n concurrency: 2,\n },\n extraFields: {\n getBatchSize: 250,\n },\n roles: {\n getBatchSize: 250,\n },\n },\n products: {\n updateBatchSize: 5,\n updateConcurrency: 2,\n inventory: {\n updateBatchSize: 2000,\n updateConcurrency: 2,\n },\n },\n orders: {\n getAllBatchSize: 250,\n shippingAddresses: {\n getAllBatchSize: 250,\n },\n products: {\n getAllBatchSize: 250,\n },\n },\n priceLists: {\n getAllBatchSize: 250,\n },\n} as const;\n","import { Config, Context, Data, Effect, Layer } from 'effect';\nimport { DEFAULTS } 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>;\n readonly getClientId: Effect.Effect<string, NoBigCommerceConfigError>;\n readonly getClientSecret: Effect.Effect<string, NoBigCommerceConfigError>;\n readonly getAccessToken: Effect.Effect<string, NoBigCommerceConfigError>;\n readonly getTimeout: Effect.Effect<number, NoBigCommerceConfigError>;\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(DEFAULTS.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(DEFAULTS.timeout.ms),\n});\n\nexport const validateBigCommerceConfig = () =>\n Effect.gen(function* () {\n const config = yield* BigCommerceConfig;\n const [storeHash, clientId, clientSecret, accessToken, timeout] = yield* Effect.all([\n config.getStoreHash,\n config.getClientId,\n config.getClientSecret,\n config.getAccessToken,\n config.getTimeout,\n ]);\n\n return {\n storeHash,\n clientId,\n clientSecret,\n accessToken,\n timeout,\n };\n });\n"],"mappings":";AAAA,SAAS,YAAY;AAEd,IAAM,sCAAN,cAAkD,KAAK;AAAA,EAC5D;AACF,EAEG;AAAC;AAEG,IAAM,+BAAN,cAA2C,KAAK;AAAA,EACrD;AACF,EAAE;AAAC;AAEI,IAAM,4BAAN,cAAwC,KAAK,YAAY,2BAA2B,EAAE;AAAC;AAEvF,IAAM,2BAAN,cAAuC,KAAK,YAAY,0BAA0B,EAAE;AAAC;AAErF,IAAM,2BAAN,cAAuC,KAAK,YAAY,0BAA0B,EAEtF;AAAC;AAEG,IAAM,6BAAN,cAAyC,KAAK,YAAY,4BAA4B,EAG1F;AAAC;AAEG,IAAM,0BAAN,cAAsC,KAAK,YAAY,yBAAyB,EAEpF;AAAC;AAEG,IAAM,kCAAN,cAA8C,KAAK;AAAA,EACxD;AACF,EAEG;AAAC;AAEG,IAAM,iC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AA,UAC3D;AAAA,UACA,MAAM,KAAK,uBAAuB,cAAc,MAAM,IAAI,6BAA6B,CAAC;AAAA,UACxF,MAAM,KAAK,uBAAuB,WAAW,MAAM,IAAI,0BAA0B,CAAC;AAAA,UAClF,MAAM,KAAK,uBAAuB,WAAW,MAAM,IAAI,yBAAyB,CAAC;AAAA,UACjF,MAAM;AAAA,YACJ,uBAAuB;AAAA,YACvB,MAAM,IAAI,yBAAyB,EAAE,SAAS,aAAa,CAAC;AAAA,UAC9D;AAAA,UACA,MAAM;AAAA,YACJ,uBAAuB;AAAA,YACvB,MAAM,IAAI,oCAAoC,EAAE,aAAa,CAAC;AAAA,UAChE;AAAA,UACA,MAAM;AAAA,YACJ,CAACC,UAASA,SAAQ;AAAA,YAClB,MACE,IAAI,2BAA2B;AAAA,cAC7B,SAAS,iBAAiB,IAAI;AAAA,cAC9B,MACE,SAAS,uBAAuB,wBAC5B,kBACA,SAAS,uBAAuB,eAC9B,SAAS,uBAAuB,kBAChC,YACA;AAAA,YACV,CAAC;AAAA,UACL;AAAA,UACA,MAAM,OAAO,MAAM,IAAI,wBAAwB,EAAE,OAAO,aAAa,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"]}
|
package/dist/companies.d.mts
CHANGED
|
@@ -37,6 +37,35 @@ declare const CreateCompanyResponseSchema: z.ZodObject<{
|
|
|
37
37
|
message: z.ZodString;
|
|
38
38
|
}, z.core.$strip>;
|
|
39
39
|
}, z.core.$strip>;
|
|
40
|
+
declare const GetCompanyResponseSchema: z.ZodObject<{
|
|
41
|
+
data: z.ZodObject<{
|
|
42
|
+
companyId: z.ZodNumber;
|
|
43
|
+
companyName: z.ZodString;
|
|
44
|
+
bcGroupName: z.ZodString;
|
|
45
|
+
companyStatus: z.ZodNumber;
|
|
46
|
+
catalogId: z.ZodNumber;
|
|
47
|
+
catalogName: z.ZodString;
|
|
48
|
+
companyEmail: z.ZodString;
|
|
49
|
+
companyPhone: z.ZodString;
|
|
50
|
+
addressLine1: z.ZodString;
|
|
51
|
+
addressLine2: z.ZodString;
|
|
52
|
+
city: z.ZodString;
|
|
53
|
+
state: z.ZodString;
|
|
54
|
+
country: z.ZodString;
|
|
55
|
+
zipCode: z.ZodString;
|
|
56
|
+
createdAt: z.ZodNumber;
|
|
57
|
+
updatedAt: z.ZodNumber;
|
|
58
|
+
uuid: z.ZodString;
|
|
59
|
+
bcGroupId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
60
|
+
extraFields: z.ZodArray<z.ZodObject<{
|
|
61
|
+
fieldName: z.ZodString;
|
|
62
|
+
fieldValue: z.ZodString;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
declare const GetCompanyInputSchema: z.ZodObject<{
|
|
67
|
+
companyId: z.ZodNumber;
|
|
68
|
+
}, z.core.$strip>;
|
|
40
69
|
|
|
41
70
|
declare const SetCompanyCreditSchema: z.ZodObject<{
|
|
42
71
|
data: z.ZodObject<{
|
|
@@ -151,6 +180,36 @@ declare const CreateCompanyUserResponseSchema: z.ZodObject<{
|
|
|
151
180
|
message: z.ZodString;
|
|
152
181
|
}, z.core.$strip>;
|
|
153
182
|
}, z.core.$strip>;
|
|
183
|
+
declare const GetUserDetailsByCustomerIdResponseSchema: z.ZodObject<{
|
|
184
|
+
code: z.ZodInt;
|
|
185
|
+
data: z.ZodObject<{
|
|
186
|
+
firstName: z.ZodString;
|
|
187
|
+
lastName: z.ZodString;
|
|
188
|
+
email: z.ZodEmail;
|
|
189
|
+
phoneNumber: z.ZodString;
|
|
190
|
+
role: z.ZodInt;
|
|
191
|
+
companyRoleId: z.ZodInt;
|
|
192
|
+
uuid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
193
|
+
extraFields: z.ZodArray<z.ZodObject<{
|
|
194
|
+
fieldName: z.ZodString;
|
|
195
|
+
fieldValue: z.ZodString;
|
|
196
|
+
}, z.core.$strip>>;
|
|
197
|
+
companyId: z.ZodInt;
|
|
198
|
+
customerId: z.ZodInt;
|
|
199
|
+
companyRoleName: z.ZodString;
|
|
200
|
+
channelList: z.ZodArray<z.ZodObject<{
|
|
201
|
+
channelId: z.ZodInt;
|
|
202
|
+
channelName: z.ZodString;
|
|
203
|
+
iconUrl: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
meta: z.ZodObject<{
|
|
207
|
+
message: z.ZodString;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
}, z.core.$strip>;
|
|
210
|
+
declare const GetUserDetailsByCustomerIdInputSchema: z.ZodObject<{
|
|
211
|
+
customerId: z.ZodInt;
|
|
212
|
+
}, z.core.$strip>;
|
|
154
213
|
|
|
155
214
|
declare const assignSalesStaffToCompany: (input: z.input<typeof AssignSalesStaffSchema>) => Effect.Effect<{
|
|
156
215
|
code: number;
|
|
@@ -181,6 +240,33 @@ declare const createCompanyUser: (data: z.input<typeof CreateCompanyUserSchema>)
|
|
|
181
240
|
|
|
182
241
|
declare const setCompanyCredit: (input: z.infer<typeof SetCompanyCreditSchema>) => Effect.Effect<Record<string, never>, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
183
242
|
|
|
243
|
+
declare const getCompanyDetails: (input: z.input<typeof GetCompanyInputSchema>) => Effect.Effect<{
|
|
244
|
+
data: {
|
|
245
|
+
companyId: number;
|
|
246
|
+
companyName: string;
|
|
247
|
+
bcGroupName: string;
|
|
248
|
+
companyStatus: number;
|
|
249
|
+
catalogId: number;
|
|
250
|
+
catalogName: string;
|
|
251
|
+
companyEmail: string;
|
|
252
|
+
companyPhone: string;
|
|
253
|
+
addressLine1: string;
|
|
254
|
+
addressLine2: string;
|
|
255
|
+
city: string;
|
|
256
|
+
state: string;
|
|
257
|
+
country: string;
|
|
258
|
+
zipCode: string;
|
|
259
|
+
createdAt: number;
|
|
260
|
+
updatedAt: number;
|
|
261
|
+
uuid: string;
|
|
262
|
+
extraFields: {
|
|
263
|
+
fieldName: string;
|
|
264
|
+
fieldValue: string;
|
|
265
|
+
}[];
|
|
266
|
+
bcGroupId?: number | null | undefined;
|
|
267
|
+
};
|
|
268
|
+
}, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
269
|
+
|
|
184
270
|
declare const findCompanyExtraFields: (criteria: z.input<typeof GetCompanyExtraFieldsCriteriaSchema>) => Effect.Effect<{
|
|
185
271
|
data: {
|
|
186
272
|
fieldName: string;
|
|
@@ -227,6 +313,34 @@ declare const getAllCompanyRolesBy: (criteria?: Omit<z.infer<typeof GetCompanyRo
|
|
|
227
313
|
roleType: number;
|
|
228
314
|
}[], SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
229
315
|
|
|
316
|
+
declare const getUserByCustomerId: (input: z.input<typeof GetUserDetailsByCustomerIdInputSchema>) => Effect.Effect<{
|
|
317
|
+
code: number;
|
|
318
|
+
data: {
|
|
319
|
+
firstName: string;
|
|
320
|
+
lastName: string;
|
|
321
|
+
email: string;
|
|
322
|
+
phoneNumber: string;
|
|
323
|
+
role: number;
|
|
324
|
+
companyRoleId: number;
|
|
325
|
+
extraFields: {
|
|
326
|
+
fieldName: string;
|
|
327
|
+
fieldValue: string;
|
|
328
|
+
}[];
|
|
329
|
+
companyId: number;
|
|
330
|
+
customerId: number;
|
|
331
|
+
companyRoleName: string;
|
|
332
|
+
channelList: {
|
|
333
|
+
channelId: number;
|
|
334
|
+
channelName: string;
|
|
335
|
+
iconUrl: string;
|
|
336
|
+
}[];
|
|
337
|
+
uuid?: string | null | undefined;
|
|
338
|
+
};
|
|
339
|
+
meta: {
|
|
340
|
+
message: string;
|
|
341
|
+
};
|
|
342
|
+
}, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
343
|
+
|
|
230
344
|
declare const setCompanyPaymentMethods: (input: z.infer<typeof SetCompanyPaymentMethodsSchema>) => Effect.Effect<Record<string, never>, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
231
345
|
|
|
232
|
-
export { AssignSalesStaffResponseSchema, AssignSalesStaffSchema, CompanyExtraFieldSchema, CompanyRoleSchema, CreateCompanyResponseSchema, CreateCompanySchema, CreateCompanyUserResponseSchema, CreateCompanyUserSchema, GetCompanyExtraFieldsCriteriaSchema, GetCompanyExtraFieldsResponseSchema, GetCompanyRolesCriteriaSchema, type GetCompanyRolesResponse, GetCompanyRolesResponseSchema, SetCompanyCreditResponseSchema, SetCompanyCreditSchema, SetCompanyPaymentMethodsResponseSchema, SetCompanyPaymentMethodsSchema, assignSalesStaffToCompany, createCompany, createCompanyUser, findCompanyExtraFields, findCompanyRoles, getAllCompanyExtraFieldsBy, getAllCompanyRolesBy, setCompanyCredit, setCompanyPaymentMethods };
|
|
346
|
+
export { AssignSalesStaffResponseSchema, AssignSalesStaffSchema, CompanyExtraFieldSchema, CompanyRoleSchema, CreateCompanyResponseSchema, CreateCompanySchema, CreateCompanyUserResponseSchema, CreateCompanyUserSchema, GetCompanyExtraFieldsCriteriaSchema, GetCompanyExtraFieldsResponseSchema, GetCompanyInputSchema, GetCompanyResponseSchema, GetCompanyRolesCriteriaSchema, type GetCompanyRolesResponse, GetCompanyRolesResponseSchema, GetUserDetailsByCustomerIdInputSchema, GetUserDetailsByCustomerIdResponseSchema, SetCompanyCreditResponseSchema, SetCompanyCreditSchema, SetCompanyPaymentMethodsResponseSchema, SetCompanyPaymentMethodsSchema, assignSalesStaffToCompany, createCompany, createCompanyUser, findCompanyExtraFields, findCompanyRoles, getAllCompanyExtraFieldsBy, getAllCompanyRolesBy, getCompanyDetails, getUserByCustomerId, setCompanyCredit, setCompanyPaymentMethods };
|
package/dist/companies.d.ts
CHANGED
|
@@ -37,6 +37,35 @@ declare const CreateCompanyResponseSchema: z.ZodObject<{
|
|
|
37
37
|
message: z.ZodString;
|
|
38
38
|
}, z.core.$strip>;
|
|
39
39
|
}, z.core.$strip>;
|
|
40
|
+
declare const GetCompanyResponseSchema: z.ZodObject<{
|
|
41
|
+
data: z.ZodObject<{
|
|
42
|
+
companyId: z.ZodNumber;
|
|
43
|
+
companyName: z.ZodString;
|
|
44
|
+
bcGroupName: z.ZodString;
|
|
45
|
+
companyStatus: z.ZodNumber;
|
|
46
|
+
catalogId: z.ZodNumber;
|
|
47
|
+
catalogName: z.ZodString;
|
|
48
|
+
companyEmail: z.ZodString;
|
|
49
|
+
companyPhone: z.ZodString;
|
|
50
|
+
addressLine1: z.ZodString;
|
|
51
|
+
addressLine2: z.ZodString;
|
|
52
|
+
city: z.ZodString;
|
|
53
|
+
state: z.ZodString;
|
|
54
|
+
country: z.ZodString;
|
|
55
|
+
zipCode: z.ZodString;
|
|
56
|
+
createdAt: z.ZodNumber;
|
|
57
|
+
updatedAt: z.ZodNumber;
|
|
58
|
+
uuid: z.ZodString;
|
|
59
|
+
bcGroupId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
60
|
+
extraFields: z.ZodArray<z.ZodObject<{
|
|
61
|
+
fieldName: z.ZodString;
|
|
62
|
+
fieldValue: z.ZodString;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
declare const GetCompanyInputSchema: z.ZodObject<{
|
|
67
|
+
companyId: z.ZodNumber;
|
|
68
|
+
}, z.core.$strip>;
|
|
40
69
|
|
|
41
70
|
declare const SetCompanyCreditSchema: z.ZodObject<{
|
|
42
71
|
data: z.ZodObject<{
|
|
@@ -151,6 +180,36 @@ declare const CreateCompanyUserResponseSchema: z.ZodObject<{
|
|
|
151
180
|
message: z.ZodString;
|
|
152
181
|
}, z.core.$strip>;
|
|
153
182
|
}, z.core.$strip>;
|
|
183
|
+
declare const GetUserDetailsByCustomerIdResponseSchema: z.ZodObject<{
|
|
184
|
+
code: z.ZodInt;
|
|
185
|
+
data: z.ZodObject<{
|
|
186
|
+
firstName: z.ZodString;
|
|
187
|
+
lastName: z.ZodString;
|
|
188
|
+
email: z.ZodEmail;
|
|
189
|
+
phoneNumber: z.ZodString;
|
|
190
|
+
role: z.ZodInt;
|
|
191
|
+
companyRoleId: z.ZodInt;
|
|
192
|
+
uuid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
193
|
+
extraFields: z.ZodArray<z.ZodObject<{
|
|
194
|
+
fieldName: z.ZodString;
|
|
195
|
+
fieldValue: z.ZodString;
|
|
196
|
+
}, z.core.$strip>>;
|
|
197
|
+
companyId: z.ZodInt;
|
|
198
|
+
customerId: z.ZodInt;
|
|
199
|
+
companyRoleName: z.ZodString;
|
|
200
|
+
channelList: z.ZodArray<z.ZodObject<{
|
|
201
|
+
channelId: z.ZodInt;
|
|
202
|
+
channelName: z.ZodString;
|
|
203
|
+
iconUrl: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
meta: z.ZodObject<{
|
|
207
|
+
message: z.ZodString;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
}, z.core.$strip>;
|
|
210
|
+
declare const GetUserDetailsByCustomerIdInputSchema: z.ZodObject<{
|
|
211
|
+
customerId: z.ZodInt;
|
|
212
|
+
}, z.core.$strip>;
|
|
154
213
|
|
|
155
214
|
declare const assignSalesStaffToCompany: (input: z.input<typeof AssignSalesStaffSchema>) => Effect.Effect<{
|
|
156
215
|
code: number;
|
|
@@ -181,6 +240,33 @@ declare const createCompanyUser: (data: z.input<typeof CreateCompanyUserSchema>)
|
|
|
181
240
|
|
|
182
241
|
declare const setCompanyCredit: (input: z.infer<typeof SetCompanyCreditSchema>) => Effect.Effect<Record<string, never>, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
183
242
|
|
|
243
|
+
declare const getCompanyDetails: (input: z.input<typeof GetCompanyInputSchema>) => Effect.Effect<{
|
|
244
|
+
data: {
|
|
245
|
+
companyId: number;
|
|
246
|
+
companyName: string;
|
|
247
|
+
bcGroupName: string;
|
|
248
|
+
companyStatus: number;
|
|
249
|
+
catalogId: number;
|
|
250
|
+
catalogName: string;
|
|
251
|
+
companyEmail: string;
|
|
252
|
+
companyPhone: string;
|
|
253
|
+
addressLine1: string;
|
|
254
|
+
addressLine2: string;
|
|
255
|
+
city: string;
|
|
256
|
+
state: string;
|
|
257
|
+
country: string;
|
|
258
|
+
zipCode: string;
|
|
259
|
+
createdAt: number;
|
|
260
|
+
updatedAt: number;
|
|
261
|
+
uuid: string;
|
|
262
|
+
extraFields: {
|
|
263
|
+
fieldName: string;
|
|
264
|
+
fieldValue: string;
|
|
265
|
+
}[];
|
|
266
|
+
bcGroupId?: number | null | undefined;
|
|
267
|
+
};
|
|
268
|
+
}, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
269
|
+
|
|
184
270
|
declare const findCompanyExtraFields: (criteria: z.input<typeof GetCompanyExtraFieldsCriteriaSchema>) => Effect.Effect<{
|
|
185
271
|
data: {
|
|
186
272
|
fieldName: string;
|
|
@@ -227,6 +313,34 @@ declare const getAllCompanyRolesBy: (criteria?: Omit<z.infer<typeof GetCompanyRo
|
|
|
227
313
|
roleType: number;
|
|
228
314
|
}[], SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
229
315
|
|
|
316
|
+
declare const getUserByCustomerId: (input: z.input<typeof GetUserDetailsByCustomerIdInputSchema>) => Effect.Effect<{
|
|
317
|
+
code: number;
|
|
318
|
+
data: {
|
|
319
|
+
firstName: string;
|
|
320
|
+
lastName: string;
|
|
321
|
+
email: string;
|
|
322
|
+
phoneNumber: string;
|
|
323
|
+
role: number;
|
|
324
|
+
companyRoleId: number;
|
|
325
|
+
extraFields: {
|
|
326
|
+
fieldName: string;
|
|
327
|
+
fieldValue: string;
|
|
328
|
+
}[];
|
|
329
|
+
companyId: number;
|
|
330
|
+
customerId: number;
|
|
331
|
+
companyRoleName: string;
|
|
332
|
+
channelList: {
|
|
333
|
+
channelId: number;
|
|
334
|
+
channelName: string;
|
|
335
|
+
iconUrl: string;
|
|
336
|
+
}[];
|
|
337
|
+
uuid?: string | null | undefined;
|
|
338
|
+
};
|
|
339
|
+
meta: {
|
|
340
|
+
message: string;
|
|
341
|
+
};
|
|
342
|
+
}, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
343
|
+
|
|
230
344
|
declare const setCompanyPaymentMethods: (input: z.infer<typeof SetCompanyPaymentMethodsSchema>) => Effect.Effect<Record<string, never>, SomeBigCommerceError | InputValidationError, BigCommerceFetcher>;
|
|
231
345
|
|
|
232
|
-
export { AssignSalesStaffResponseSchema, AssignSalesStaffSchema, CompanyExtraFieldSchema, CompanyRoleSchema, CreateCompanyResponseSchema, CreateCompanySchema, CreateCompanyUserResponseSchema, CreateCompanyUserSchema, GetCompanyExtraFieldsCriteriaSchema, GetCompanyExtraFieldsResponseSchema, GetCompanyRolesCriteriaSchema, type GetCompanyRolesResponse, GetCompanyRolesResponseSchema, SetCompanyCreditResponseSchema, SetCompanyCreditSchema, SetCompanyPaymentMethodsResponseSchema, SetCompanyPaymentMethodsSchema, assignSalesStaffToCompany, createCompany, createCompanyUser, findCompanyExtraFields, findCompanyRoles, getAllCompanyExtraFieldsBy, getAllCompanyRolesBy, setCompanyCredit, setCompanyPaymentMethods };
|
|
346
|
+
export { AssignSalesStaffResponseSchema, AssignSalesStaffSchema, CompanyExtraFieldSchema, CompanyRoleSchema, CreateCompanyResponseSchema, CreateCompanySchema, CreateCompanyUserResponseSchema, CreateCompanyUserSchema, GetCompanyExtraFieldsCriteriaSchema, GetCompanyExtraFieldsResponseSchema, GetCompanyInputSchema, GetCompanyResponseSchema, GetCompanyRolesCriteriaSchema, type GetCompanyRolesResponse, GetCompanyRolesResponseSchema, GetUserDetailsByCustomerIdInputSchema, GetUserDetailsByCustomerIdResponseSchema, SetCompanyCreditResponseSchema, SetCompanyCreditSchema, SetCompanyPaymentMethodsResponseSchema, SetCompanyPaymentMethodsSchema, assignSalesStaffToCompany, createCompany, createCompanyUser, findCompanyExtraFields, findCompanyRoles, getAllCompanyExtraFieldsBy, getAllCompanyRolesBy, getCompanyDetails, getUserByCustomerId, setCompanyCredit, setCompanyPaymentMethods };
|
package/dist/companies.js
CHANGED
|
@@ -40,8 +40,12 @@ __export(companies_exports, {
|
|
|
40
40
|
CreateCompanyUserSchema: () => CreateCompanyUserSchema,
|
|
41
41
|
GetCompanyExtraFieldsCriteriaSchema: () => GetCompanyExtraFieldsCriteriaSchema,
|
|
42
42
|
GetCompanyExtraFieldsResponseSchema: () => GetCompanyExtraFieldsResponseSchema,
|
|
43
|
+
GetCompanyInputSchema: () => GetCompanyInputSchema,
|
|
44
|
+
GetCompanyResponseSchema: () => GetCompanyResponseSchema,
|
|
43
45
|
GetCompanyRolesCriteriaSchema: () => GetCompanyRolesCriteriaSchema,
|
|
44
46
|
GetCompanyRolesResponseSchema: () => GetCompanyRolesResponseSchema,
|
|
47
|
+
GetUserDetailsByCustomerIdInputSchema: () => GetUserDetailsByCustomerIdInputSchema,
|
|
48
|
+
GetUserDetailsByCustomerIdResponseSchema: () => GetUserDetailsByCustomerIdResponseSchema,
|
|
45
49
|
SetCompanyCreditResponseSchema: () => SetCompanyCreditResponseSchema,
|
|
46
50
|
SetCompanyCreditSchema: () => SetCompanyCreditSchema,
|
|
47
51
|
SetCompanyPaymentMethodsResponseSchema: () => SetCompanyPaymentMethodsResponseSchema,
|
|
@@ -53,6 +57,8 @@ __export(companies_exports, {
|
|
|
53
57
|
findCompanyRoles: () => findCompanyRoles,
|
|
54
58
|
getAllCompanyExtraFieldsBy: () => getAllCompanyExtraFieldsBy,
|
|
55
59
|
getAllCompanyRolesBy: () => getAllCompanyRolesBy,
|
|
60
|
+
getCompanyDetails: () => getCompanyDetails,
|
|
61
|
+
getUserByCustomerId: () => getUserByCustomerId,
|
|
56
62
|
setCompanyCredit: () => setCompanyCredit,
|
|
57
63
|
setCompanyPaymentMethods: () => setCompanyPaymentMethods
|
|
58
64
|
});
|
|
@@ -290,9 +296,16 @@ var getBase = ({
|
|
|
290
296
|
}
|
|
291
297
|
return `${DEFAULTS.bigcommerceUrls.regular}/[storeHash]/${version}/${path}`;
|
|
292
298
|
};
|
|
299
|
+
async function safeJson(response) {
|
|
300
|
+
const text = await response.text();
|
|
301
|
+
if (!text || text.trim() === "") {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
return JSON.parse(text);
|
|
305
|
+
}
|
|
293
306
|
function processSuccessResponse(response, schema) {
|
|
294
307
|
return import_effect5.Effect.tryPromise({
|
|
295
|
-
try: () => response
|
|
308
|
+
try: () => safeJson(response),
|
|
296
309
|
catch: (error) => new BigCommerceInvalidResponseError({ cause: error })
|
|
297
310
|
}).pipe(
|
|
298
311
|
import_effect5.Effect.tapError(
|
|
@@ -307,7 +320,7 @@ function processSuccessResponse(response, schema) {
|
|
|
307
320
|
var processErrorResponse = (response) => {
|
|
308
321
|
const code = response.status;
|
|
309
322
|
return import_effect5.Effect.tryPromise({
|
|
310
|
-
try: () => response
|
|
323
|
+
try: () => safeJson(response),
|
|
311
324
|
catch: (error) => new BigCommerceInvalidResponseError({ cause: error })
|
|
312
325
|
}).pipe(
|
|
313
326
|
import_effect5.Effect.tapError((error) => import_effect5.Effect.logError("Error parsing error response", error.cause)),
|
|
@@ -401,6 +414,35 @@ var CreateCompanyResponseSchema = z.object({
|
|
|
401
414
|
message: z.string()
|
|
402
415
|
})
|
|
403
416
|
});
|
|
417
|
+
var GetCompanyResponseSchema = z.object({
|
|
418
|
+
data: z.object({
|
|
419
|
+
companyId: z.number(),
|
|
420
|
+
companyName: z.string(),
|
|
421
|
+
bcGroupName: z.string(),
|
|
422
|
+
companyStatus: z.number(),
|
|
423
|
+
catalogId: z.number(),
|
|
424
|
+
catalogName: z.string(),
|
|
425
|
+
companyEmail: z.string(),
|
|
426
|
+
companyPhone: z.string(),
|
|
427
|
+
addressLine1: z.string(),
|
|
428
|
+
addressLine2: z.string(),
|
|
429
|
+
city: z.string(),
|
|
430
|
+
state: z.string(),
|
|
431
|
+
country: z.string(),
|
|
432
|
+
zipCode: z.string(),
|
|
433
|
+
createdAt: z.number(),
|
|
434
|
+
updatedAt: z.number(),
|
|
435
|
+
uuid: z.string(),
|
|
436
|
+
bcGroupId: z.number().nullable().optional(),
|
|
437
|
+
extraFields: z.object({
|
|
438
|
+
fieldName: z.string(),
|
|
439
|
+
fieldValue: z.string()
|
|
440
|
+
}).array()
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
var GetCompanyInputSchema = z.object({
|
|
444
|
+
companyId: z.number()
|
|
445
|
+
});
|
|
404
446
|
|
|
405
447
|
// src/bigcommerce-entities/companies/schemas/credit.schemas.ts
|
|
406
448
|
var z2 = __toESM(require("zod"));
|
|
@@ -516,6 +558,36 @@ var CreateCompanyUserResponseSchema = z7.object({
|
|
|
516
558
|
message: z7.string()
|
|
517
559
|
})
|
|
518
560
|
});
|
|
561
|
+
var GetUserDetailsByCustomerIdResponseSchema = z7.object({
|
|
562
|
+
code: z7.int(),
|
|
563
|
+
data: z7.object({
|
|
564
|
+
firstName: z7.string(),
|
|
565
|
+
lastName: z7.string(),
|
|
566
|
+
email: z7.email(),
|
|
567
|
+
phoneNumber: z7.string(),
|
|
568
|
+
role: z7.int(),
|
|
569
|
+
companyRoleId: z7.int(),
|
|
570
|
+
uuid: z7.string().optional().nullable(),
|
|
571
|
+
extraFields: z7.object({
|
|
572
|
+
fieldName: z7.string(),
|
|
573
|
+
fieldValue: z7.string()
|
|
574
|
+
}).array(),
|
|
575
|
+
companyId: z7.int(),
|
|
576
|
+
customerId: z7.int(),
|
|
577
|
+
companyRoleName: z7.string(),
|
|
578
|
+
channelList: z7.object({
|
|
579
|
+
channelId: z7.int(),
|
|
580
|
+
channelName: z7.string(),
|
|
581
|
+
iconUrl: z7.string()
|
|
582
|
+
}).array()
|
|
583
|
+
}),
|
|
584
|
+
meta: z7.object({
|
|
585
|
+
message: z7.string()
|
|
586
|
+
})
|
|
587
|
+
});
|
|
588
|
+
var GetUserDetailsByCustomerIdInputSchema = z7.object({
|
|
589
|
+
customerId: z7.int()
|
|
590
|
+
});
|
|
519
591
|
|
|
520
592
|
// src/bigcommerce-entities/companies/assign-sales-staff.ts
|
|
521
593
|
var assignSalesStaffToCompanyBatch = (staffId, assignments) => import_effect8.Effect.gen(function* () {
|
|
@@ -599,13 +671,30 @@ var setCompanyCredit = (input) => import_effect11.Effect.gen(function* () {
|
|
|
599
671
|
);
|
|
600
672
|
});
|
|
601
673
|
|
|
602
|
-
// src/bigcommerce-entities/companies/get-company
|
|
674
|
+
// src/bigcommerce-entities/companies/get-company.ts
|
|
603
675
|
var import_effect12 = require("effect");
|
|
676
|
+
var getCompanyDetails = (input) => import_effect12.Effect.gen(function* () {
|
|
677
|
+
const { companyId } = yield* validateInput(GetCompanyInputSchema, input);
|
|
678
|
+
const fetcher = yield* BigCommerceFetcher;
|
|
679
|
+
return yield* import_effect12.Effect.retry(
|
|
680
|
+
fetcher.fetch({
|
|
681
|
+
isB2B: true,
|
|
682
|
+
method: "GET",
|
|
683
|
+
path: `companies/${companyId}`,
|
|
684
|
+
resultSchema: GetCompanyResponseSchema,
|
|
685
|
+
version: "v3"
|
|
686
|
+
}),
|
|
687
|
+
DEFAULTS.retry.policy
|
|
688
|
+
);
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// src/bigcommerce-entities/companies/get-company-fields.ts
|
|
692
|
+
var import_effect13 = require("effect");
|
|
604
693
|
var import_node_querystring = require("querystring");
|
|
605
|
-
var findCompanyExtraFields = (criteria) =>
|
|
694
|
+
var findCompanyExtraFields = (criteria) => import_effect13.Effect.gen(function* () {
|
|
606
695
|
const validatedCriteria = yield* validateInput(GetCompanyExtraFieldsCriteriaSchema, criteria);
|
|
607
696
|
const fetcher = yield* BigCommerceFetcher;
|
|
608
|
-
return yield*
|
|
697
|
+
return yield* import_effect13.Effect.retry(
|
|
609
698
|
fetcher.fetch({
|
|
610
699
|
isB2B: true,
|
|
611
700
|
method: "GET",
|
|
@@ -617,7 +706,7 @@ var findCompanyExtraFields = (criteria) => import_effect12.Effect.gen(function*
|
|
|
617
706
|
DEFAULTS.retry.policy
|
|
618
707
|
);
|
|
619
708
|
});
|
|
620
|
-
var getAllCompanyExtraFieldsBy = (criteria) =>
|
|
709
|
+
var getAllCompanyExtraFieldsBy = (criteria) => import_effect13.Effect.gen(function* () {
|
|
621
710
|
let offset = 0;
|
|
622
711
|
const limit = DEFAULTS.companies.extraFields.getBatchSize;
|
|
623
712
|
let hasMore = true;
|
|
@@ -639,12 +728,12 @@ var getAllCompanyExtraFieldsBy = (criteria) => import_effect12.Effect.gen(functi
|
|
|
639
728
|
});
|
|
640
729
|
|
|
641
730
|
// src/bigcommerce-entities/companies/get-company-roles.ts
|
|
642
|
-
var
|
|
731
|
+
var import_effect14 = require("effect");
|
|
643
732
|
var import_node_querystring2 = require("querystring");
|
|
644
|
-
var findCompanyRoles = (criteria) =>
|
|
733
|
+
var findCompanyRoles = (criteria) => import_effect14.Effect.gen(function* () {
|
|
645
734
|
const validatedCriteria = yield* validateInput(GetCompanyRolesCriteriaSchema, criteria);
|
|
646
735
|
const fetcher = yield* BigCommerceFetcher;
|
|
647
|
-
return yield*
|
|
736
|
+
return yield* import_effect14.Effect.retry(
|
|
648
737
|
fetcher.fetch({
|
|
649
738
|
isB2B: true,
|
|
650
739
|
method: "GET",
|
|
@@ -656,7 +745,7 @@ var findCompanyRoles = (criteria) => import_effect13.Effect.gen(function* () {
|
|
|
656
745
|
DEFAULTS.retry.policy
|
|
657
746
|
);
|
|
658
747
|
});
|
|
659
|
-
var getAllCompanyRolesBy = (criteria) =>
|
|
748
|
+
var getAllCompanyRolesBy = (criteria) => import_effect14.Effect.gen(function* () {
|
|
660
749
|
let hasMore = true;
|
|
661
750
|
const data = [];
|
|
662
751
|
let offset = 0;
|
|
@@ -677,12 +766,29 @@ var getAllCompanyRolesBy = (criteria) => import_effect13.Effect.gen(function* ()
|
|
|
677
766
|
return data;
|
|
678
767
|
});
|
|
679
768
|
|
|
769
|
+
// src/bigcommerce-entities/companies/get-user-by-customer-id.ts
|
|
770
|
+
var import_effect15 = require("effect");
|
|
771
|
+
var getUserByCustomerId = (input) => import_effect15.Effect.gen(function* () {
|
|
772
|
+
const { customerId } = yield* validateInput(GetUserDetailsByCustomerIdInputSchema, input);
|
|
773
|
+
const fetcher = yield* BigCommerceFetcher;
|
|
774
|
+
return yield* import_effect15.Effect.retry(
|
|
775
|
+
fetcher.fetch({
|
|
776
|
+
isB2B: true,
|
|
777
|
+
method: "GET",
|
|
778
|
+
path: `users/customer/${customerId}`,
|
|
779
|
+
resultSchema: GetUserDetailsByCustomerIdResponseSchema,
|
|
780
|
+
version: "v3"
|
|
781
|
+
}),
|
|
782
|
+
DEFAULTS.retry.policy
|
|
783
|
+
);
|
|
784
|
+
});
|
|
785
|
+
|
|
680
786
|
// src/bigcommerce-entities/companies/set-payment-methods.ts
|
|
681
|
-
var
|
|
682
|
-
var setCompanyPaymentMethods = (input) =>
|
|
787
|
+
var import_effect16 = require("effect");
|
|
788
|
+
var setCompanyPaymentMethods = (input) => import_effect16.Effect.gen(function* () {
|
|
683
789
|
const { companyId, data } = yield* validateInput(SetCompanyPaymentMethodsSchema, input);
|
|
684
790
|
const fetcher = yield* BigCommerceFetcher;
|
|
685
|
-
return yield*
|
|
791
|
+
return yield* import_effect16.Effect.retry(
|
|
686
792
|
fetcher.fetch({
|
|
687
793
|
body: data,
|
|
688
794
|
isB2B: true,
|
|
@@ -706,8 +812,12 @@ var setCompanyPaymentMethods = (input) => import_effect14.Effect.gen(function* (
|
|
|
706
812
|
CreateCompanyUserSchema,
|
|
707
813
|
GetCompanyExtraFieldsCriteriaSchema,
|
|
708
814
|
GetCompanyExtraFieldsResponseSchema,
|
|
815
|
+
GetCompanyInputSchema,
|
|
816
|
+
GetCompanyResponseSchema,
|
|
709
817
|
GetCompanyRolesCriteriaSchema,
|
|
710
818
|
GetCompanyRolesResponseSchema,
|
|
819
|
+
GetUserDetailsByCustomerIdInputSchema,
|
|
820
|
+
GetUserDetailsByCustomerIdResponseSchema,
|
|
711
821
|
SetCompanyCreditResponseSchema,
|
|
712
822
|
SetCompanyCreditSchema,
|
|
713
823
|
SetCompanyPaymentMethodsResponseSchema,
|
|
@@ -719,6 +829,8 @@ var setCompanyPaymentMethods = (input) => import_effect14.Effect.gen(function* (
|
|
|
719
829
|
findCompanyRoles,
|
|
720
830
|
getAllCompanyExtraFieldsBy,
|
|
721
831
|
getAllCompanyRolesBy,
|
|
832
|
+
getCompanyDetails,
|
|
833
|
+
getUserByCustomerId,
|
|
722
834
|
setCompanyCredit,
|
|
723
835
|
setCompanyPaymentMethods
|
|
724
836
|
});
|