@opexa/portal-sdk 0.59.145 → 0.59.147
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 +1762 -1762
- package/dist/{chunk-ITHR4H7D.js → chunk-324UNFU6.js} +47 -3
- package/dist/chunk-324UNFU6.js.map +1 -0
- package/dist/{chunk-BTV72WJH.js → chunk-77N5VUZS.js} +2 -2
- package/dist/chunk-77N5VUZS.js.map +1 -0
- package/dist/{chunk-7Y7FWND5.js → chunk-ZBLHFIBW.js} +3 -3
- package/dist/chunk-ZBLHFIBW.js.map +1 -0
- package/dist/graphql-client-B_tCbUDO.d.cts +30 -0
- package/dist/graphql-client-CjJ2PWjG.d.ts +30 -0
- package/dist/index-L0Y9nBAa.d.cts +55 -0
- package/dist/index-L0Y9nBAa.d.ts +55 -0
- package/dist/index.cjs +147 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +105 -5
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +44 -0
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +4 -3
- package/dist/services/index.d.ts +4 -3
- package/dist/services/index.js +2 -2
- package/dist/types/index.cjs +4 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/{types-CTtgnovB.d.cts → types-Bg1jKSWb.d.ts} +3 -3
- package/dist/{types-m4mQIRGr.d.ts → types-XZX_dOi6.d.cts} +3 -3
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-7Y7FWND5.js.map +0 -1
- package/dist/chunk-BTV72WJH.js.map +0 -1
- package/dist/chunk-ITHR4H7D.js.map +0 -1
- package/dist/graphql-client-Cr5nXEyQ.d.cts +0 -58
- package/dist/graphql-client-Cr5nXEyQ.d.ts +0 -58
|
@@ -39,5 +39,5 @@ var ERROR_MAP = {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export { callIfFn, gql, statusCodeToOperationError };
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-77N5VUZS.js.map
|
|
43
|
+
//# sourceMappingURL=chunk-77N5VUZS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/gql.ts","../src/utils/call-if-fn.ts","../src/utils/status-code-to-operation-error.ts"],"names":[],"mappings":";AAAO,SAAS,GAAA,CAAI,YAAkC,MAAA,EAAmB;AACxE,EAAA,IAAI,MAAA,GAAS,EAAA;AAEb,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,MAAM,CAAA,IAAK,OAAA,CAAQ,SAAQ,EAAG;AAChD,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,EAAA,CAAG,KAAK,CAAA,IAAK,EAAA;AAElC,IAAA,MAAA,GAAS,CAAA,EAAG,MAAM,CAAA,EAAG,MAAM,GAAG,KAAK,CAAA,CAAA;AAAA,EACpC;AAEA,EAAA,OAAO,OAAO,IAAA,EAAK;AACpB;;;ACVA,SAAS,WACR,KAAA,EACuC;AACvC,EAAA,OAAO,OAAO,KAAA,KAAU,UAAA;AACzB;AAEO,SAAS,QAAA,CACf,UACG,IAAA,EACF;AACD,EAAA,IAAI,UAAA,CAAyB,KAAK,CAAA,EAAG;AACpC,IAAA,OAAO,KAAA,CAAM,GAAG,IAAI,CAAA;AAAA,EACrB,CAAA,MAAO;AACN,IAAA,OAAO,KAAA;AAAA,EACR;AACD;;;ACbO,SAAS,0BAAA,CACf,OACA,OAAA,EAC4B;AAC5B,EAAA,MAAM,CAAA,GAAI,UAAU,KAAK,CAAA,GAAI,UAAU,KAAK,CAAA,GAAI,UAAU,GAAG,CAAA;AAE7D,EAAA,OAAO;AAAA,IACN,MAAM,CAAA,CAAE,IAAA;AAAA,IACR,OAAA,EAAS,WAAW,CAAA,CAAE;AAAA,GACvB;AACD;AAEA,IAAM,SAAA,GAAuD;AAAA,EAC5D,GAAA,EAAK,EAAE,IAAA,EAAM,gBAAA,EAAkB,SAAS,aAAA,EAAc;AAAA,EACtD,GAAA,EAAK,EAAE,IAAA,EAAM,kBAAA,EAAoB,SAAS,cAAA,EAAe;AAAA,EACzD,GAAA,EAAK,EAAE,IAAA,EAAM,eAAA,EAAiB,SAAS,WAAA,EAAY;AAAA,EACnD,GAAA,EAAK,EAAE,IAAA,EAAM,cAAA,EAAgB,SAAS,WAAA,EAAY;AAAA,EAClD,GAAA,EAAK,EAAE,IAAA,EAAM,oBAAA,EAAsB,SAAS,iBAAA,EAAkB;AAAA,EAC9D,GAAA,EAAK,EAAE,IAAA,EAAM,qBAAA,EAAuB,SAAS,mBAAA,EAAoB;AAAA,EACjE,GAAA,EAAK,EAAE,IAAA,EAAM,yBAAA,EAA2B,SAAS,uBAAA;AAClD,CAAA","file":"chunk-77N5VUZS.js","sourcesContent":["export function gql(strings: TemplateStringsArray, ...values: unknown[]) {\n\tlet result = '';\n\n\tfor (const [index, string] of strings.entries()) {\n\t\tconst value = values.at(index) ?? '';\n\n\t\tresult = `${result}${string}${value}`;\n\t}\n\n\treturn result.trim();\n}\n","function isFunction<Return, Args = never>(\n\tvalue: unknown | ((...args: Args[]) => Return),\n): value is (...args: Args[]) => Return {\n\treturn typeof value === 'function';\n}\n\nexport function callIfFn<Return, Args = never>(\n\tvalue: Return | ((...args: Args[]) => Return),\n\t...args: Args[]\n) {\n\tif (isFunction<Return, Args>(value)) {\n\t\treturn value(...args);\n\t} else {\n\t\treturn value;\n\t}\n}\n","import type { HttpError, OperationError } from '../types/index.js';\n\nexport function statusCodeToOperationError(\n\tvalue: number,\n\tmessage?: string,\n): OperationError<HttpError> {\n\tconst e = ERROR_MAP[value] ? ERROR_MAP[value] : ERROR_MAP[500];\n\n\treturn {\n\t\tname: e.name,\n\t\tmessage: message ?? e.message,\n\t};\n}\n\nconst ERROR_MAP: Record<number, OperationError<HttpError>> = {\n\t400: { name: 'HttpBadRequest', message: 'Bad Request' },\n\t401: { name: 'HttpUnauthorized', message: 'Unauthorized' },\n\t403: { name: 'HttpForbidden', message: 'Forbidden' },\n\t404: { name: 'HttpNotFound', message: 'Not Found' },\n\t408: { name: 'HttpRequestTimeout', message: 'Request Timeout' },\n\t429: { name: 'HttpTooManyRequests', message: 'Too Many Requests' },\n\t500: { name: 'HttpInternalServerError', message: 'Internal Server Error' },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callIfFn, statusCodeToOperationError } from './chunk-
|
|
1
|
+
import { callIfFn, statusCodeToOperationError } from './chunk-77N5VUZS.js';
|
|
2
2
|
|
|
3
3
|
// src/utils/is-plain-object.ts
|
|
4
4
|
function isPlainObject(value) {
|
|
@@ -221,5 +221,5 @@ function mergeHeaders(i, j) {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
export { GraphQLClient, isPlainObject };
|
|
224
|
-
//# sourceMappingURL=chunk-
|
|
225
|
-
//# sourceMappingURL=chunk-
|
|
224
|
+
//# sourceMappingURL=chunk-ZBLHFIBW.js.map
|
|
225
|
+
//# sourceMappingURL=chunk-ZBLHFIBW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/is-plain-object.ts","../src/utils/flatten.ts","../src/utils/graphql-client.ts"],"names":[],"mappings":";;;AAAO,SAAS,cAAc,KAAA,EAA8C;AAC3E,EAAA,OACC,MAAA,CAAO,UAAU,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA,KAAM,iBAAA,IAC1C,MAAA,CAAO,KAAK,CAAA,KAAM,KAAA;AAEpB;;;ACHO,SAAS,QAAQ,KAAA,EAAoC;AAC3D,EAAA,MAAM,SAGA,EAAC;AAEP,E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,OAAO,KAAA,EAAuB;AACtC,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ,GAAG,EAAE,IAAA,EAAK;AACxC;AAEA,SAAS,YAAA,CAAa,GAA4B,CAAA,EAA4B;AAC7E,EAAA,IAAI,CAAC,GAAG,OAAO,CAAA;AACf,EAAA,IAAI,CAAC,GAAG,OAAO,CAAA;AAEf,EAAA,MAAM,CAAA,GAAI,IAAI,OAAA,EAAQ;AAEtB,EAAA,IAAI,QAAQ,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,GAAG,CAAA,KAAM;AAChC,IAAA,CAAA,CAAE,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,EACd,CAAC,CAAA;AAED,EAAA,IAAI,QAAQ,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,GAAG,CAAA,KAAM;AAChC,IAAA,CAAA,CAAE,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,EACd,CAAC,CAAA;AAED,EAAA,OAAO,CAAA;AACR","file":"chunk-ZBLHFIBW.js","sourcesContent":["export function isPlainObject(value: unknown): value is Record<string, any> {\n\treturn (\n\t\tObject.prototype.toString.call(value) === '[object Object]' &&\n\t\tObject(value) === value\n\t);\n}\n","import { isPlainObject } from './is-plain-object.js';\n\nexport function flatten(value: Record<string, any> | any[]) {\n\tconst result: {\n\t\tkey: string[];\n\t\tvalue: any;\n\t}[] = [];\n\n\tfunction fn(o: Record<string, any>, parentKeys: string[] = []) {\n\t\tfor (const k in o) {\n\t\t\tconst v = o[k];\n\n\t\t\tif (isPlainObject(v)) {\n\t\t\t\tfn(v, [...parentKeys, k]);\n\t\t\t} else if (Array.isArray(v)) {\n\t\t\t\tfn(arrayToObject(v), [...parentKeys, k]);\n\t\t\t} else {\n\t\t\t\tresult.push({\n\t\t\t\t\tkey: [...parentKeys, k],\n\t\t\t\t\tvalue: v,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tfn(value);\n\n\treturn result;\n}\n\nfunction arrayToObject(array: unknown[]) {\n\treturn array.reduce<Record<string, any>>((o, v, i) => {\n\t\to[i] = v;\n\t\treturn o;\n\t}, {});\n}\n","import type { GenericObject, OperationResult } from '../types/index.js';\nimport { callIfFn } from './call-if-fn.js';\nimport { flatten } from './flatten.js';\nimport { statusCodeToOperationError } from './status-code-to-operation-error.js';\n\ntype ModifiableKey =\n\t| 'mode'\n\t| 'cache'\n\t| 'signal'\n\t| 'headers'\n\t| 'integrity'\n\t| 'keepalive'\n\t| 'credentials';\n\ntype Modifiable = {\n\t[K in ModifiableKey]: Request[K];\n};\n\nexport interface ModifiedRequest\n\textends Readonly<Omit<Request, ModifiableKey>>,\n\t\tModifiable {}\n\nexport type GraphQLClientMiddleware = (\n\trequest: ModifiedRequest,\n) => ModifiedRequest | Promise<ModifiedRequest>;\n\nexport interface GraphQLClientFetchOptions extends Omit<RequestInit, 'body'> {}\n\nexport interface GraphQLClientConfig {\n\tfetch?: typeof globalThis.fetch | null;\n\tfetchOptions?: GraphQLClientFetchOptions;\n\tmiddlewares?: GraphQLClientMiddleware[];\n}\n\n/* ref: https://www.apollographql.com/docs/apollo-server/data/errors/#graphql_parse_failed */\ntype GraphQLErrorExtensionCode =\n\t| 'FORBIDDEN'\n\t| 'UNAUTHORIZED'\n\t| 'BAD_REQUEST'\n\t| 'BAD_USER_INPUT'\n\t| 'INTERNAL_SERVER_ERROR'\n\t| 'ACCESS_TOKEN_EXPIRED';\n\ninterface GraphQLErrorExtensions {\n\tcode: GraphQLErrorExtensionCode;\n\tstacktrace: string[];\n}\n\ninterface GraphQLErrorLocation {\n\tline: number;\n\tcolumn: number;\n}\n\ninterface GraphQLError {\n\tpath: string[];\n\tmessage?: string;\n\textensions?: GraphQLErrorExtensions;\n\tlocations: GraphQLErrorLocation[];\n}\n\ntype Getter<T> = () => T;\n\nexport class GraphQLClient {\n\tprivate url: string;\n\tprivate config: Getter<GraphQLClientConfig> | GraphQLClientConfig;\n\n\tconstructor(\n\t\turl: string,\n\t\tconfig: Getter<GraphQLClientConfig> | GraphQLClientConfig = {},\n\t) {\n\t\tthis.url = url;\n\t\tthis.config = config;\n\t}\n\n\tasync request<Data, Variables extends GenericObject = GenericObject>(\n\t\tquery: string,\n\t\tvariables?: Variables,\n\t\tuserOptions?: GraphQLClientFetchOptions,\n\t) {\n\t\tconst config = callIfFn(this.config);\n\t\tconst options = mergeFetchOptions(\n\t\t\t{\n\t\t\t\t...config?.fetchOptions,\n\t\t\t\theaders: new Headers(config?.fetchOptions?.headers),\n\t\t\t},\n\t\t\tuserOptions,\n\t\t);\n\n\t\tconst url = new URL(this.url);\n\t\tconst operationInfo = getOperationInfo(query);\n\n\t\tif (operationInfo) {\n\t\t\turl.searchParams.set(`_${operationInfo.type}`, operationInfo.name);\n\t\t}\n\n\t\tconst method = options.method?.toUpperCase() ?? 'POST';\n\t\tconst headers = new Headers(options.headers);\n\n\t\tlet body: string | undefined;\n\n\t\tif (method === 'GET') {\n\t\t\turl.searchParams.set('query', minify(query));\n\n\t\t\tif (variables) {\n\t\t\t\turl.searchParams.set('variables', JSON.stringify(variables));\n\t\t\t}\n\n\t\t\theaders.delete('Content-Type');\n\t\t} else {\n\t\t\tbody = JSON.stringify({\n\t\t\t\tquery,\n\t\t\t\tvariables,\n\t\t\t});\n\n\t\t\theaders.set('Content-Type', 'application/json');\n\t\t}\n\n\t\theaders.set('Accept', 'application/json');\n\n\t\tconst req = await this.runMiddlewares(\n\t\t\tnew Request(url, {\n\t\t\t\t...options,\n\t\t\t\tbody,\n\t\t\t\theaders,\n\t\t\t\tmethod,\n\t\t\t}),\n\t\t\tconfig?.middlewares ?? [],\n\t\t);\n\n\t\treturn await this.exec<Data>(req);\n\t}\n\n\t/** Single file upload */\n\tasync upload<Data, Variables extends GenericObject = GenericObject>(\n\t\tquery: string,\n\t\tvariables: Variables,\n\t\toptions?: GraphQLClientFetchOptions,\n\t) {\n\t\tconst cfg = callIfFn(this.config);\n\t\tconst opts = mergeFetchOptions(\n\t\t\t{\n\t\t\t\t...cfg?.fetchOptions,\n\t\t\t\theaders: new Headers(cfg?.fetchOptions?.headers),\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\n\t\tconst body = this.createUploadBody(query, variables);\n\t\tconst headers = new Headers(opts.headers);\n\n\t\theaders.delete('Content-Type');\n\n\t\tconst url = new URL(this.url);\n\t\tconst operationInfo = getOperationInfo(query);\n\n\t\tif (operationInfo) {\n\t\t\turl.searchParams.set(`_${operationInfo.type}`, operationInfo.name);\n\t\t}\n\n\t\tconst req = await this.runMiddlewares(\n\t\t\tnew Request(url, {\n\t\t\t\t...opts,\n\t\t\t\tbody,\n\t\t\t\theaders,\n\t\t\t\tmethod: 'POST',\n\t\t\t}),\n\t\t\tcfg?.middlewares ?? [],\n\t\t);\n\n\t\treturn await this.exec<Data>(req);\n\t}\n\n\tprivate async exec<T>(request: Request): Promise<OperationResult<never, T>> {\n\t\tconst config = callIfFn(this.config);\n\n\t\tconst fetch_ = config.fetch ?? fetch;\n\n\t\ttry {\n\t\t\tconst res = await fetch_(request);\n\n\t\t\tif (!res.ok) {\n\t\t\t\treturn { ok: false, error: statusCodeToOperationError(res.status) };\n\t\t\t}\n\n\t\t\tconst json = await res.json();\n\t\t\tconst data = json.data;\n\t\t\tconst error = json.errors?.at(0) as GraphQLError | undefined;\n\n\t\t\tif (error) {\n\t\t\t\tif (\n\t\t\t\t\terror.extensions?.code === 'FORBIDDEN' ||\n\t\t\t\t\terror.extensions?.code === 'ACCESS_TOKEN_EXPIRED'\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tok: false,\n\t\t\t\t\t\terror: statusCodeToOperationError(403, error.message),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (error.extensions?.code === 'UNAUTHORIZED') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tok: false,\n\t\t\t\t\t\terror: statusCodeToOperationError(401, error.message),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\terror.extensions?.code === 'BAD_USER_INPUT' ||\n\t\t\t\t\terror.extensions?.code === 'BAD_REQUEST'\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tok: false,\n\t\t\t\t\t\terror: statusCodeToOperationError(400, error.message),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t/* Fallback for unknown error codes */\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\terror: statusCodeToOperationError(500, error.message),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tdata,\n\t\t\t};\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: statusCodeToOperationError(500),\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate async runMiddlewares(\n\t\treq: ModifiedRequest,\n\t\tmiddlewares: GraphQLClientMiddleware[],\n\t): Promise<ModifiedRequest> {\n\t\tlet result = req.clone();\n\n\t\tfor (const middleware of middlewares) {\n\t\t\tresult = await middleware(result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate createUploadBody<Variables extends GenericObject = GenericObject>(\n\t\tquery: string,\n\t\tvariables: Variables,\n\t) {\n\t\tconst files = flatten(variables).filter(\n\t\t\t(o) => o.value instanceof File || o.value instanceof Blob,\n\t\t);\n\n\t\tconst body = new FormData();\n\n\t\tbody.append(\n\t\t\t'operations',\n\t\t\tJSON.stringify({\n\t\t\t\tquery,\n\t\t\t\tvariables,\n\t\t\t}),\n\t\t);\n\n\t\tconst map: GenericObject = {};\n\n\t\tfiles.forEach((o, i) => {\n\t\t\tmap[i.toString()] = [`variables.${o.key.join('.')}`];\n\t\t});\n\n\t\tbody.append('map', JSON.stringify(map));\n\n\t\tfiles.forEach((o, i) => {\n\t\t\tbody.append(i.toString(), o.value);\n\t\t});\n\n\t\treturn body;\n\t}\n}\n\nfunction getOperationInfo(query: string) {\n\tconst l = query.match(/(query|mutation)\\s+(\\w+)/);\n\n\tif (!l) return null;\n\n\tconst k = l.at(1);\n\tconst v = l.at(2);\n\n\treturn k && v ? { type: k, name: v } : null;\n}\n\nfunction mergeFetchOptions(\n\ti: GraphQLClientFetchOptions | undefined,\n\tj: GraphQLClientFetchOptions | undefined,\n): GraphQLClientFetchOptions {\n\tif (!i) return j ?? {};\n\tif (!j) return i ?? {};\n\n\treturn {\n\t\t...i,\n\t\t...j,\n\n\t\theaders: mergeHeaders(i.headers, j.headers),\n\t};\n}\n\nfunction minify(input: string): string {\n\treturn input.replace(/\\s+/g, ' ').trim();\n}\n\nfunction mergeHeaders(i: HeadersInit | undefined, j: HeadersInit | undefined) {\n\tif (!i) return j;\n\tif (!j) return i;\n\n\tconst h = new Headers();\n\n\tnew Headers(i).forEach((v, k) => {\n\t\th.append(k, v);\n\t});\n\n\tnew Headers(j).forEach((v, k) => {\n\t\th.append(k, v);\n\t});\n\n\treturn h;\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { G as GenericObject, a as OperationResult } from './index-L0Y9nBAa.cjs';
|
|
2
|
+
|
|
3
|
+
type ModifiableKey = 'mode' | 'cache' | 'signal' | 'headers' | 'integrity' | 'keepalive' | 'credentials';
|
|
4
|
+
type Modifiable = {
|
|
5
|
+
[K in ModifiableKey]: Request[K];
|
|
6
|
+
};
|
|
7
|
+
interface ModifiedRequest extends Readonly<Omit<Request, ModifiableKey>>, Modifiable {
|
|
8
|
+
}
|
|
9
|
+
type GraphQLClientMiddleware = (request: ModifiedRequest) => ModifiedRequest | Promise<ModifiedRequest>;
|
|
10
|
+
interface GraphQLClientFetchOptions extends Omit<RequestInit, 'body'> {
|
|
11
|
+
}
|
|
12
|
+
interface GraphQLClientConfig {
|
|
13
|
+
fetch?: typeof globalThis.fetch | null;
|
|
14
|
+
fetchOptions?: GraphQLClientFetchOptions;
|
|
15
|
+
middlewares?: GraphQLClientMiddleware[];
|
|
16
|
+
}
|
|
17
|
+
type Getter<T> = () => T;
|
|
18
|
+
declare class GraphQLClient {
|
|
19
|
+
private url;
|
|
20
|
+
private config;
|
|
21
|
+
constructor(url: string, config?: Getter<GraphQLClientConfig> | GraphQLClientConfig);
|
|
22
|
+
request<Data, Variables extends GenericObject = GenericObject>(query: string, variables?: Variables, userOptions?: GraphQLClientFetchOptions): Promise<OperationResult<never, Data>>;
|
|
23
|
+
/** Single file upload */
|
|
24
|
+
upload<Data, Variables extends GenericObject = GenericObject>(query: string, variables: Variables, options?: GraphQLClientFetchOptions): Promise<OperationResult<never, Data>>;
|
|
25
|
+
private exec;
|
|
26
|
+
private runMiddlewares;
|
|
27
|
+
private createUploadBody;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type GraphQLClientMiddleware as G, type ModifiedRequest as M, GraphQLClient as a, type GraphQLClientFetchOptions as b, type GraphQLClientConfig as c };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { G as GenericObject, a as OperationResult } from './index-L0Y9nBAa.js';
|
|
2
|
+
|
|
3
|
+
type ModifiableKey = 'mode' | 'cache' | 'signal' | 'headers' | 'integrity' | 'keepalive' | 'credentials';
|
|
4
|
+
type Modifiable = {
|
|
5
|
+
[K in ModifiableKey]: Request[K];
|
|
6
|
+
};
|
|
7
|
+
interface ModifiedRequest extends Readonly<Omit<Request, ModifiableKey>>, Modifiable {
|
|
8
|
+
}
|
|
9
|
+
type GraphQLClientMiddleware = (request: ModifiedRequest) => ModifiedRequest | Promise<ModifiedRequest>;
|
|
10
|
+
interface GraphQLClientFetchOptions extends Omit<RequestInit, 'body'> {
|
|
11
|
+
}
|
|
12
|
+
interface GraphQLClientConfig {
|
|
13
|
+
fetch?: typeof globalThis.fetch | null;
|
|
14
|
+
fetchOptions?: GraphQLClientFetchOptions;
|
|
15
|
+
middlewares?: GraphQLClientMiddleware[];
|
|
16
|
+
}
|
|
17
|
+
type Getter<T> = () => T;
|
|
18
|
+
declare class GraphQLClient {
|
|
19
|
+
private url;
|
|
20
|
+
private config;
|
|
21
|
+
constructor(url: string, config?: Getter<GraphQLClientConfig> | GraphQLClientConfig);
|
|
22
|
+
request<Data, Variables extends GenericObject = GenericObject>(query: string, variables?: Variables, userOptions?: GraphQLClientFetchOptions): Promise<OperationResult<never, Data>>;
|
|
23
|
+
/** Single file upload */
|
|
24
|
+
upload<Data, Variables extends GenericObject = GenericObject>(query: string, variables: Variables, options?: GraphQLClientFetchOptions): Promise<OperationResult<never, Data>>;
|
|
25
|
+
private exec;
|
|
26
|
+
private runMiddlewares;
|
|
27
|
+
private createUploadBody;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type GraphQLClientMiddleware as G, type ModifiedRequest as M, GraphQLClient as a, type GraphQLClientFetchOptions as b, type GraphQLClientConfig as c };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Site-specific catalogs are supplied by consumers, not bundled into the SDK. */
|
|
2
|
+
interface JourneyPolicy {
|
|
3
|
+
signupType: 'number_only' | 'regular';
|
|
4
|
+
kycRequired: boolean;
|
|
5
|
+
/** Minimum first-deposit amount in the catalog currency's major units. */
|
|
6
|
+
minimumFtd: number;
|
|
7
|
+
}
|
|
8
|
+
interface JourneyCatalog<Id extends string = string> {
|
|
9
|
+
version: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
journeys: Record<Id, JourneyPolicy>;
|
|
12
|
+
}
|
|
13
|
+
interface SelectedJourney<Id extends string = string> extends JourneyPolicy {
|
|
14
|
+
id: Id;
|
|
15
|
+
version: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
}
|
|
18
|
+
declare const USER_JOURNEY_STORAGE_KEY = "userJourney";
|
|
19
|
+
/** Validate external session data and return a detached snapshot of known fields. */
|
|
20
|
+
declare function parseSelectedJourney(value: unknown): SelectedJourney | null;
|
|
21
|
+
/** Validate a site's JSON catalog without adding any site-specific journey rules. */
|
|
22
|
+
declare function parseJourneyCatalog(value: unknown): JourneyCatalog | null;
|
|
23
|
+
|
|
24
|
+
type GenericObject = Record<string, any>;
|
|
25
|
+
type Assign<Target, Source> = Omit<Target, keyof Source> & Source;
|
|
26
|
+
type Alias<T> = T & {
|
|
27
|
+
_?: never;
|
|
28
|
+
};
|
|
29
|
+
type Maybe<T> = T | null | undefined;
|
|
30
|
+
type HttpError = /* 400 */ 'HttpBadRequest' | /* 401 */ 'HttpUnauthorized' | /* 403 */ 'HttpForbidden' | /* 404 */ 'HttpNotFound' | /* 408 */ 'HttpRequestTimeout' | /* 429 */ 'HttpTooManyRequests' | /* 500 */ 'HttpInternalServerError';
|
|
31
|
+
type OperationError<T extends string = string> = {
|
|
32
|
+
name: T;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
type OperationResult<Error extends string = never, Data = never> = [
|
|
36
|
+
Data
|
|
37
|
+
] extends [never] ? {
|
|
38
|
+
ok: false;
|
|
39
|
+
data?: never;
|
|
40
|
+
error: [Error] extends [never] ? OperationError<HttpError | 'UnknownError'> : OperationError<Error> | OperationError<HttpError | 'UnknownError'>;
|
|
41
|
+
} | {
|
|
42
|
+
ok: true;
|
|
43
|
+
data?: never;
|
|
44
|
+
error?: never;
|
|
45
|
+
} : {
|
|
46
|
+
ok: false;
|
|
47
|
+
data?: never;
|
|
48
|
+
error: [Error] extends [never] ? OperationError<HttpError | 'UnknownError'> : OperationError<Error> | OperationError<HttpError | 'UnknownError'>;
|
|
49
|
+
} | {
|
|
50
|
+
ok: true;
|
|
51
|
+
data: Data;
|
|
52
|
+
error?: never;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { type Assign as A, type GenericObject as G, type HttpError as H, type JourneyCatalog as J, type Maybe as M, type OperationError as O, type SelectedJourney as S, USER_JOURNEY_STORAGE_KEY as U, type OperationResult as a, type JourneyPolicy as b, parseJourneyCatalog as c, type Alias as d, parseSelectedJourney as p };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Site-specific catalogs are supplied by consumers, not bundled into the SDK. */
|
|
2
|
+
interface JourneyPolicy {
|
|
3
|
+
signupType: 'number_only' | 'regular';
|
|
4
|
+
kycRequired: boolean;
|
|
5
|
+
/** Minimum first-deposit amount in the catalog currency's major units. */
|
|
6
|
+
minimumFtd: number;
|
|
7
|
+
}
|
|
8
|
+
interface JourneyCatalog<Id extends string = string> {
|
|
9
|
+
version: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
journeys: Record<Id, JourneyPolicy>;
|
|
12
|
+
}
|
|
13
|
+
interface SelectedJourney<Id extends string = string> extends JourneyPolicy {
|
|
14
|
+
id: Id;
|
|
15
|
+
version: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
}
|
|
18
|
+
declare const USER_JOURNEY_STORAGE_KEY = "userJourney";
|
|
19
|
+
/** Validate external session data and return a detached snapshot of known fields. */
|
|
20
|
+
declare function parseSelectedJourney(value: unknown): SelectedJourney | null;
|
|
21
|
+
/** Validate a site's JSON catalog without adding any site-specific journey rules. */
|
|
22
|
+
declare function parseJourneyCatalog(value: unknown): JourneyCatalog | null;
|
|
23
|
+
|
|
24
|
+
type GenericObject = Record<string, any>;
|
|
25
|
+
type Assign<Target, Source> = Omit<Target, keyof Source> & Source;
|
|
26
|
+
type Alias<T> = T & {
|
|
27
|
+
_?: never;
|
|
28
|
+
};
|
|
29
|
+
type Maybe<T> = T | null | undefined;
|
|
30
|
+
type HttpError = /* 400 */ 'HttpBadRequest' | /* 401 */ 'HttpUnauthorized' | /* 403 */ 'HttpForbidden' | /* 404 */ 'HttpNotFound' | /* 408 */ 'HttpRequestTimeout' | /* 429 */ 'HttpTooManyRequests' | /* 500 */ 'HttpInternalServerError';
|
|
31
|
+
type OperationError<T extends string = string> = {
|
|
32
|
+
name: T;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
type OperationResult<Error extends string = never, Data = never> = [
|
|
36
|
+
Data
|
|
37
|
+
] extends [never] ? {
|
|
38
|
+
ok: false;
|
|
39
|
+
data?: never;
|
|
40
|
+
error: [Error] extends [never] ? OperationError<HttpError | 'UnknownError'> : OperationError<Error> | OperationError<HttpError | 'UnknownError'>;
|
|
41
|
+
} | {
|
|
42
|
+
ok: true;
|
|
43
|
+
data?: never;
|
|
44
|
+
error?: never;
|
|
45
|
+
} : {
|
|
46
|
+
ok: false;
|
|
47
|
+
data?: never;
|
|
48
|
+
error: [Error] extends [never] ? OperationError<HttpError | 'UnknownError'> : OperationError<Error> | OperationError<HttpError | 'UnknownError'>;
|
|
49
|
+
} | {
|
|
50
|
+
ok: true;
|
|
51
|
+
data: Data;
|
|
52
|
+
error?: never;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { type Assign as A, type GenericObject as G, type HttpError as H, type JourneyCatalog as J, type Maybe as M, type OperationError as O, type SelectedJourney as S, USER_JOURNEY_STORAGE_KEY as U, type OperationResult as a, type JourneyPolicy as b, parseJourneyCatalog as c, type Alias as d, parseSelectedJourney as p };
|
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,51 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
9
9
|
|
|
10
10
|
var cookies__default = /*#__PURE__*/_interopDefault(cookies);
|
|
11
11
|
|
|
12
|
-
// src/sdk/
|
|
12
|
+
// src/sdk/journey.ts
|
|
13
|
+
var USER_JOURNEY_STORAGE_KEY = "userJourney";
|
|
14
|
+
function parseSelectedJourney(value) {
|
|
15
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const candidate = value;
|
|
19
|
+
if (typeof candidate.id !== "string" || !candidate.id.trim() || typeof candidate.version !== "number" || !Number.isSafeInteger(candidate.version) || candidate.version <= 0 || typeof candidate.currency !== "string" || !candidate.currency.trim() || candidate.signupType !== "number_only" && candidate.signupType !== "regular" || typeof candidate.kycRequired !== "boolean" || typeof candidate.minimumFtd !== "number" || !Number.isFinite(candidate.minimumFtd) || candidate.minimumFtd <= 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
id: candidate.id,
|
|
24
|
+
version: candidate.version,
|
|
25
|
+
currency: candidate.currency,
|
|
26
|
+
signupType: candidate.signupType,
|
|
27
|
+
kycRequired: candidate.kycRequired,
|
|
28
|
+
minimumFtd: candidate.minimumFtd
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function parseJourneyCatalog(value) {
|
|
32
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
33
|
+
const catalog = value;
|
|
34
|
+
if (typeof catalog.version !== "number" || !Number.isSafeInteger(catalog.version) || catalog.version <= 0 || typeof catalog.currency !== "string" || !catalog.currency.trim() || !catalog.journeys || typeof catalog.journeys !== "object" || Array.isArray(catalog.journeys))
|
|
35
|
+
return null;
|
|
36
|
+
const entries = Object.entries(catalog.journeys);
|
|
37
|
+
if (!entries.length) return null;
|
|
38
|
+
const journeys = /* @__PURE__ */ Object.create(null);
|
|
39
|
+
for (const [id, policy] of entries) {
|
|
40
|
+
if (!policy || typeof policy !== "object" || Array.isArray(policy))
|
|
41
|
+
return null;
|
|
42
|
+
const parsed = parseSelectedJourney({
|
|
43
|
+
...policy,
|
|
44
|
+
id,
|
|
45
|
+
version: catalog.version,
|
|
46
|
+
currency: catalog.currency
|
|
47
|
+
});
|
|
48
|
+
if (!parsed) return null;
|
|
49
|
+
journeys[id] = {
|
|
50
|
+
signupType: parsed.signupType,
|
|
51
|
+
kycRequired: parsed.kycRequired,
|
|
52
|
+
minimumFtd: parsed.minimumFtd
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return { version: catalog.version, currency: catalog.currency, journeys };
|
|
56
|
+
}
|
|
13
57
|
|
|
14
58
|
// src/sdk/object-type.ts
|
|
15
59
|
var ObjectType = {
|
|
@@ -335,6 +379,9 @@ var GAME_SESSION_QUERY = {
|
|
|
335
379
|
var CREATE_GAME_SESSION_MUTATION = gql`
|
|
336
380
|
mutation CreateGameSession($input: CreateGameSessionInput!) {
|
|
337
381
|
createGameSession(input: $input) {
|
|
382
|
+
... on BetLimitExceededError {
|
|
383
|
+
__typename
|
|
384
|
+
}
|
|
338
385
|
... on GameDoesNotExistError {
|
|
339
386
|
__typename
|
|
340
387
|
}
|
|
@@ -911,6 +958,9 @@ var DEPOSIT_RECORDS_QUERY = gql`
|
|
|
911
958
|
var CREATE_GCASH_DEPOSIT_MUTATION = gql`
|
|
912
959
|
mutation CreateGCashDeposit($input: CreateGCashDepositInput!) {
|
|
913
960
|
createGCashDeposit(input: $input) {
|
|
961
|
+
... on DepositLimitReachedError {
|
|
962
|
+
__typename
|
|
963
|
+
}
|
|
914
964
|
... on DepositPromoMaximumAmountExceededError {
|
|
915
965
|
__typename
|
|
916
966
|
}
|
|
@@ -941,6 +991,9 @@ var CREATE_GCASH_DEPOSIT_MUTATION = gql`
|
|
|
941
991
|
var CREATE_GCASH_WEBPAY_DEPOSIT_MUTATION = gql`
|
|
942
992
|
mutation CreateGCashWebpayDeposit($input: CreateGCashWebpayDepositInput!) {
|
|
943
993
|
createGCashWebpayDeposit(input: $input) {
|
|
994
|
+
... on DepositLimitReachedError {
|
|
995
|
+
__typename
|
|
996
|
+
}
|
|
944
997
|
... on DepositPromoMaximumAmountExceededError {
|
|
945
998
|
__typename
|
|
946
999
|
}
|
|
@@ -971,6 +1024,9 @@ var CREATE_GCASH_WEBPAY_DEPOSIT_MUTATION = gql`
|
|
|
971
1024
|
var CREATE_MAYA_WEBPAY_DEPOSIT_MUTATION = gql`
|
|
972
1025
|
mutation CreateMayaWebpayDeposit($input: CreateMayaWebpayDepositInput!) {
|
|
973
1026
|
createMayaWebpayDeposit(input: $input) {
|
|
1027
|
+
... on DepositLimitReachedError {
|
|
1028
|
+
__typename
|
|
1029
|
+
}
|
|
974
1030
|
... on DepositPromoMaximumAmountExceededError {
|
|
975
1031
|
__typename
|
|
976
1032
|
}
|
|
@@ -998,6 +1054,9 @@ var CREATE_MAYA_WEBPAY_DEPOSIT_MUTATION = gql`
|
|
|
998
1054
|
var CREATE_MAYA_DEPOSIT_MUTATION = gql`
|
|
999
1055
|
mutation CreateMayaDeposit($input: CreateMayaDepositInput!) {
|
|
1000
1056
|
createMayaDeposit(input: $input) {
|
|
1057
|
+
... on DepositLimitReachedError {
|
|
1058
|
+
__typename
|
|
1059
|
+
}
|
|
1001
1060
|
... on DepositPromoMaximumAmountExceededError {
|
|
1002
1061
|
__typename
|
|
1003
1062
|
}
|
|
@@ -1058,6 +1117,9 @@ var CREATE_TEST_DEPOSIT_MUTATION = gql`
|
|
|
1058
1117
|
var CREATE_MAYA_APP_DEPOSIT_MUTATION = gql`
|
|
1059
1118
|
mutation CreateMayaAppDeposit($input: CreateMayaAppDepositInput!) {
|
|
1060
1119
|
createMayaAppDeposit(input: $input) {
|
|
1120
|
+
... on DepositLimitReachedError {
|
|
1121
|
+
__typename
|
|
1122
|
+
}
|
|
1061
1123
|
... on DepositPromoMaximumAmountExceededError {
|
|
1062
1124
|
__typename
|
|
1063
1125
|
}
|
|
@@ -1085,6 +1147,9 @@ var CREATE_MAYA_APP_DEPOSIT_MUTATION = gql`
|
|
|
1085
1147
|
var CREATE_AIO_QRPH_DEPOSIT_MUTATION = gql`
|
|
1086
1148
|
mutation CreateAIOQRPHDeposit($input: CreateAIOQRPHDepositInput!) {
|
|
1087
1149
|
createAIOQRPHDeposit(input: $input) {
|
|
1150
|
+
... on DepositLimitReachedError {
|
|
1151
|
+
__typename
|
|
1152
|
+
}
|
|
1088
1153
|
... on DepositPromoMaximumAmountExceededError {
|
|
1089
1154
|
__typename
|
|
1090
1155
|
}
|
|
@@ -1118,6 +1183,9 @@ var CREATE_AIO_QRPH_DEPOSIT_MUTATION = gql`
|
|
|
1118
1183
|
var CREATE_AIO_GCASH_DEPOSIT_MUTATION = gql`
|
|
1119
1184
|
mutation CreateAiOGCashDeposit($input: CreateAiOGCashDepositInput!) {
|
|
1120
1185
|
createAiOGCashDeposit(input: $input) {
|
|
1186
|
+
... on DepositLimitReachedError {
|
|
1187
|
+
__typename
|
|
1188
|
+
}
|
|
1121
1189
|
... on DepositPromoMaximumAmountExceededError {
|
|
1122
1190
|
__typename
|
|
1123
1191
|
}
|
|
@@ -1148,6 +1216,9 @@ var CREATE_AIO_GCASH_DEPOSIT_MUTATION = gql`
|
|
|
1148
1216
|
var CREATE_AIO_PAY_MAYA_DEPOSIT_MUTATION = gql`
|
|
1149
1217
|
mutation CreateAiOPayMayaDeposit($input: CreateAiOPayMayaDepositInput!) {
|
|
1150
1218
|
createAiOPayMayaDeposit(input: $input) {
|
|
1219
|
+
... on DepositLimitReachedError {
|
|
1220
|
+
__typename
|
|
1221
|
+
}
|
|
1151
1222
|
... on DepositPromoMaximumAmountExceededError {
|
|
1152
1223
|
__typename
|
|
1153
1224
|
}
|
|
@@ -1178,6 +1249,9 @@ var CREATE_AIO_PAY_MAYA_DEPOSIT_MUTATION = gql`
|
|
|
1178
1249
|
var CREATE_AIO_GRAB_PAY_DEPOSIT_MUTATION = gql`
|
|
1179
1250
|
mutation CreateAiOGrabPayDeposit($input: CreateAiOGrabPayDepositInput!) {
|
|
1180
1251
|
createAiOGrabPayDeposit(input: $input) {
|
|
1252
|
+
... on DepositLimitReachedError {
|
|
1253
|
+
__typename
|
|
1254
|
+
}
|
|
1181
1255
|
... on DepositPromoMaximumAmountExceededError {
|
|
1182
1256
|
__typename
|
|
1183
1257
|
}
|
|
@@ -1210,6 +1284,9 @@ var CREATE_AIO_PALAWAN_PAY_DEPOSIT_MUTATION = gql`
|
|
|
1210
1284
|
$input: CreateAiOPalawanPayDepositInput!
|
|
1211
1285
|
) {
|
|
1212
1286
|
createAiOPalawanPayDeposit(input: $input) {
|
|
1287
|
+
... on DepositLimitReachedError {
|
|
1288
|
+
__typename
|
|
1289
|
+
}
|
|
1213
1290
|
... on DepositPromoMaximumAmountExceededError {
|
|
1214
1291
|
__typename
|
|
1215
1292
|
}
|
|
@@ -1242,6 +1319,9 @@ var CREATE_AIO_ONLINE_BANK_DEPOSIT_MUTATION = gql`
|
|
|
1242
1319
|
$input: CreateAIOOnlineBankDepositInput!
|
|
1243
1320
|
) {
|
|
1244
1321
|
createAIOOnlineBankDeposit(input: $input) {
|
|
1322
|
+
... on DepositLimitReachedError {
|
|
1323
|
+
__typename
|
|
1324
|
+
}
|
|
1245
1325
|
... on DepositPromoMaximumAmountExceededError {
|
|
1246
1326
|
__typename
|
|
1247
1327
|
}
|
|
@@ -1272,6 +1352,9 @@ var CREATE_AIO_ONLINE_BANK_DEPOSIT_MUTATION = gql`
|
|
|
1272
1352
|
var CREATE_MANUAL_BANK_DEPOSIT_MUTATION = gql`
|
|
1273
1353
|
mutation CreateManualBankDeposit($input: CreateManualBankDepositInput!) {
|
|
1274
1354
|
createManualBankDeposit(input: $input) {
|
|
1355
|
+
... on DepositLimitReachedError {
|
|
1356
|
+
__typename
|
|
1357
|
+
}
|
|
1275
1358
|
... on WalletDoesNotExistError {
|
|
1276
1359
|
__typename
|
|
1277
1360
|
}
|
|
@@ -1308,6 +1391,9 @@ var CREATE_MANUAL_BANK_DEPOSIT_MUTATION = gql`
|
|
|
1308
1391
|
var CREATE_MANUAL_UPI_DEPOSIT_MUTATION = gql`
|
|
1309
1392
|
mutation CreateManualUPIDeposit($input: CreateManualUPIDepositInput!) {
|
|
1310
1393
|
createManualUPIDeposit(input: $input) {
|
|
1394
|
+
... on DepositLimitReachedError {
|
|
1395
|
+
__typename
|
|
1396
|
+
}
|
|
1311
1397
|
... on DepositPromoMaximumAmountExceededError {
|
|
1312
1398
|
__typename
|
|
1313
1399
|
}
|
|
@@ -4152,6 +4238,8 @@ var _GAME_NODE_QUERY = gql`
|
|
|
4152
4238
|
// src/services/utils.ts
|
|
4153
4239
|
function createOperationError(code) {
|
|
4154
4240
|
const messages = {
|
|
4241
|
+
BetLimitExceededError: "Bet limit exceeded, please try again tomorrow",
|
|
4242
|
+
DepositLimitReachedError: "Deposit limit reached, please try again tomorrow",
|
|
4155
4243
|
PointsNotDivisibleBy100Error: "Please input points that are multiples of 100.",
|
|
4156
4244
|
MaximumBonusesCountLimitExceededError: "Maximum bonuses reached",
|
|
4157
4245
|
InvalidPromoCodeError: "Invalid Promo Code",
|
|
@@ -11220,11 +11308,13 @@ var Sdk = class {
|
|
|
11220
11308
|
logger;
|
|
11221
11309
|
cache;
|
|
11222
11310
|
config;
|
|
11311
|
+
journeyCatalog;
|
|
11223
11312
|
/**
|
|
11224
11313
|
* Stores the member domain for use in future mutations/queries
|
|
11225
11314
|
*/
|
|
11226
11315
|
memberDomain = null;
|
|
11227
11316
|
constructor(config) {
|
|
11317
|
+
this.journeyCatalog = config.journeyCatalog;
|
|
11228
11318
|
captureFingerprintPreference();
|
|
11229
11319
|
const {
|
|
11230
11320
|
/**/
|
|
@@ -11234,7 +11324,7 @@ var Sdk = class {
|
|
|
11234
11324
|
environment,
|
|
11235
11325
|
authApiBaseUrl,
|
|
11236
11326
|
logs
|
|
11237
|
-
} = Object.assign(defaultConfig, config);
|
|
11327
|
+
} = Object.assign({}, defaultConfig, config);
|
|
11238
11328
|
const production = environment === "production";
|
|
11239
11329
|
const logger = new Logger({
|
|
11240
11330
|
enabled: logs
|
|
@@ -11267,6 +11357,7 @@ var Sdk = class {
|
|
|
11267
11357
|
this._middleware = config.middleware ?? ((req) => req);
|
|
11268
11358
|
const graphqlClientConfig = () => ({
|
|
11269
11359
|
middlewares: [
|
|
11360
|
+
this.userJourneyMiddleware,
|
|
11270
11361
|
/**/
|
|
11271
11362
|
this.authMiddleware,
|
|
11272
11363
|
this.fingerprintMiddleware,
|
|
@@ -11302,6 +11393,7 @@ var Sdk = class {
|
|
|
11302
11393
|
const publicAccountService = new AccountService(
|
|
11303
11394
|
new GraphQLClient(accountUrl, () => ({
|
|
11304
11395
|
middlewares: [
|
|
11396
|
+
this.userJourneyMiddleware,
|
|
11305
11397
|
this.fingerprintMiddleware,
|
|
11306
11398
|
this.miscMiddleware,
|
|
11307
11399
|
this.testHeaderMiddleware,
|
|
@@ -11381,6 +11473,56 @@ var Sdk = class {
|
|
|
11381
11473
|
};
|
|
11382
11474
|
this.collectMetaDetails();
|
|
11383
11475
|
this.initMarketDomain();
|
|
11476
|
+
this.captureUserJourney();
|
|
11477
|
+
}
|
|
11478
|
+
/** Capture a valid URL journey for this browser tab, including SPA navigation. */
|
|
11479
|
+
captureUserJourney(url) {
|
|
11480
|
+
if (typeof window === "undefined") return;
|
|
11481
|
+
try {
|
|
11482
|
+
const id = new URL(
|
|
11483
|
+
url?.toString() ?? window.location.href,
|
|
11484
|
+
window.location.href
|
|
11485
|
+
).searchParams.get("journey");
|
|
11486
|
+
if (id && this.findUserJourney(id)) {
|
|
11487
|
+
sessionStorage.setItem(USER_JOURNEY_STORAGE_KEY, id);
|
|
11488
|
+
}
|
|
11489
|
+
} catch {
|
|
11490
|
+
}
|
|
11491
|
+
}
|
|
11492
|
+
getUserJourneyRegType() {
|
|
11493
|
+
return this.readUserJourney()?.signupType ?? null;
|
|
11494
|
+
}
|
|
11495
|
+
getUserJourneyMinFTD() {
|
|
11496
|
+
return this.readUserJourney()?.minimumFtd ?? null;
|
|
11497
|
+
}
|
|
11498
|
+
getUserJourneyIsKycSkippable() {
|
|
11499
|
+
const journey = this.readUserJourney();
|
|
11500
|
+
return journey ? !journey.kycRequired : null;
|
|
11501
|
+
}
|
|
11502
|
+
findUserJourney(id) {
|
|
11503
|
+
const catalog = this.journeyCatalog;
|
|
11504
|
+
if (!catalog || !Object.hasOwn(catalog.journeys, id)) return null;
|
|
11505
|
+
return parseSelectedJourney({
|
|
11506
|
+
...catalog.journeys[id],
|
|
11507
|
+
id,
|
|
11508
|
+
version: catalog.version,
|
|
11509
|
+
currency: catalog.currency
|
|
11510
|
+
});
|
|
11511
|
+
}
|
|
11512
|
+
readUserJourney() {
|
|
11513
|
+
if (typeof window === "undefined") return null;
|
|
11514
|
+
try {
|
|
11515
|
+
const id = sessionStorage.getItem(USER_JOURNEY_STORAGE_KEY);
|
|
11516
|
+
return id ? this.findUserJourney(id) : null;
|
|
11517
|
+
} catch {
|
|
11518
|
+
return null;
|
|
11519
|
+
}
|
|
11520
|
+
}
|
|
11521
|
+
get userJourneyMiddleware() {
|
|
11522
|
+
return (request) => {
|
|
11523
|
+
this.captureUserJourney();
|
|
11524
|
+
return request;
|
|
11525
|
+
};
|
|
11384
11526
|
}
|
|
11385
11527
|
_fetch = null;
|
|
11386
11528
|
_middleware;
|
|
@@ -14189,5 +14331,8 @@ exports.ENDPOINTS = ENDPOINTS;
|
|
|
14189
14331
|
exports.ObjectType = ObjectType;
|
|
14190
14332
|
exports.Sdk = Sdk;
|
|
14191
14333
|
exports.Transformer = Transformer;
|
|
14334
|
+
exports.USER_JOURNEY_STORAGE_KEY = USER_JOURNEY_STORAGE_KEY;
|
|
14335
|
+
exports.parseJourneyCatalog = parseJourneyCatalog;
|
|
14336
|
+
exports.parseSelectedJourney = parseSelectedJourney;
|
|
14192
14337
|
//# sourceMappingURL=index.cjs.map
|
|
14193
14338
|
//# sourceMappingURL=index.cjs.map
|