@commercelayer/cli-core 5.0.0-oclif3.1 → 5.0.0-oclif3.11

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 (83) hide show
  1. package/lib/index.d.mts +593 -0
  2. package/lib/index.d.ts +593 -0
  3. package/lib/index.js +11 -0
  4. package/lib/index.mjs +11 -0
  5. package/package.json +30 -37
  6. package/lib/cjs/api.d.ts +0 -41
  7. package/lib/cjs/api.js +0 -1
  8. package/lib/cjs/application.d.ts +0 -34
  9. package/lib/cjs/application.js +0 -1
  10. package/lib/cjs/color.d.ts +0 -107
  11. package/lib/cjs/color.js +0 -1
  12. package/lib/cjs/command.d.ts +0 -21
  13. package/lib/cjs/command.js +0 -1
  14. package/lib/cjs/config.d.ts +0 -92
  15. package/lib/cjs/config.js +0 -1
  16. package/lib/cjs/filter.d.ts +0 -10
  17. package/lib/cjs/filter.js +0 -1
  18. package/lib/cjs/help.d.ts +0 -17
  19. package/lib/cjs/help.js +0 -5
  20. package/lib/cjs/index.d.ts +0 -19
  21. package/lib/cjs/index.js +0 -1
  22. package/lib/cjs/inflector.d.ts +0 -26
  23. package/lib/cjs/inflector.js +0 -1
  24. package/lib/cjs/jsonapi.d.ts +0 -2
  25. package/lib/cjs/jsonapi.js +0 -1
  26. package/lib/cjs/output.d.ts +0 -28
  27. package/lib/cjs/output.js +0 -3
  28. package/lib/cjs/raw.d.ts +0 -12
  29. package/lib/cjs/raw.js +0 -1
  30. package/lib/cjs/schema.d.ts +0 -2
  31. package/lib/cjs/schema.js +0 -1
  32. package/lib/cjs/style.d.ts +0 -14
  33. package/lib/cjs/style.js +0 -1
  34. package/lib/cjs/symbol.d.ts +0 -2
  35. package/lib/cjs/symbol.js +0 -1
  36. package/lib/cjs/text.d.ts +0 -6
  37. package/lib/cjs/text.js +0 -1
  38. package/lib/cjs/token.d.ts +0 -58
  39. package/lib/cjs/token.js +0 -1
  40. package/lib/cjs/update.d.ts +0 -7
  41. package/lib/cjs/update.js +0 -4
  42. package/lib/cjs/util.d.ts +0 -9
  43. package/lib/cjs/util.js +0 -2
  44. package/lib/esm/api.d.ts +0 -41
  45. package/lib/esm/api.js +0 -1
  46. package/lib/esm/application.d.ts +0 -34
  47. package/lib/esm/application.js +0 -1
  48. package/lib/esm/color.d.ts +0 -107
  49. package/lib/esm/color.js +0 -1
  50. package/lib/esm/command.d.ts +0 -21
  51. package/lib/esm/command.js +0 -1
  52. package/lib/esm/config.d.ts +0 -92
  53. package/lib/esm/config.js +0 -1
  54. package/lib/esm/filter.d.ts +0 -10
  55. package/lib/esm/filter.js +0 -1
  56. package/lib/esm/help.d.ts +0 -17
  57. package/lib/esm/help.js +0 -5
  58. package/lib/esm/index.d.ts +0 -19
  59. package/lib/esm/index.js +0 -1
  60. package/lib/esm/inflector.d.ts +0 -26
  61. package/lib/esm/inflector.js +0 -1
  62. package/lib/esm/jsonapi.d.ts +0 -2
  63. package/lib/esm/jsonapi.js +0 -1
  64. package/lib/esm/output.d.ts +0 -28
  65. package/lib/esm/output.js +0 -3
  66. package/lib/esm/raw.d.ts +0 -12
  67. package/lib/esm/raw.js +0 -1
  68. package/lib/esm/schema.d.ts +0 -2
  69. package/lib/esm/schema.js +0 -1
  70. package/lib/esm/style.d.ts +0 -14
  71. package/lib/esm/style.js +0 -1
  72. package/lib/esm/symbol.d.ts +0 -2
  73. package/lib/esm/symbol.js +0 -1
  74. package/lib/esm/text.d.ts +0 -6
  75. package/lib/esm/text.js +0 -1
  76. package/lib/esm/token.d.ts +0 -58
  77. package/lib/esm/token.js +0 -1
  78. package/lib/esm/update.d.ts +0 -7
  79. package/lib/esm/update.js +0 -4
  80. package/lib/esm/util.d.ts +0 -9
  81. package/lib/esm/util.js +0 -2
  82. package/lib/tsconfig.esm.tsbuildinfo +0 -1
  83. package/lib/tsconfig.tsbuildinfo +0 -1
@@ -1,26 +0,0 @@
1
- declare const _Inflector: {
2
- uncountableWords: string[];
3
- pluralRules: (string | RegExp)[][];
4
- singularRules: (string | RegExp)[][];
5
- nonTitlecasedWords: string[];
6
- idSuffix: RegExp;
7
- underbar: RegExp;
8
- spaceOrUnderbar: RegExp;
9
- uppercase: RegExp;
10
- underbarPrefix: RegExp;
11
- applyRules: (str: string, rules: Array<Array<string | RegExp>>, skip: string[], override?: string) => string;
12
- pluralize: (str: string, plural?: string) => string;
13
- singularize: (str: string, singular?: string) => string;
14
- camelize: (str: string, lowFirstLetter?: boolean) => string;
15
- underscore: (str: string) => string;
16
- humanize: (str: string, lowFirstLetter: boolean) => string;
17
- capitalize: (str: string) => string;
18
- dasherize: (str: string) => string;
19
- camel2words: (str: string, allFirstUpper: boolean) => string;
20
- demodulize: (str: string) => string;
21
- tableize: (str: string) => string;
22
- classify: (str: string) => string;
23
- foreignKey: (str: string, dropIdUbar: boolean) => string;
24
- ordinalize: (str: string) => string;
25
- };
26
- export default _Inflector;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const _Inflector={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,i,n,s){if(s)e=s;else if(!n.includes(e.toLowerCase())){for(let r=0;r<i.length;r++)if(e.match(i[r][0])){e=e.replace(i[r][0],i[r][1]);break}}return e},pluralize:function(e,i){return _Inflector.applyRules(e,_Inflector.pluralRules,_Inflector.uncountableWords,i)},singularize:function(e,i){return _Inflector.applyRules(e,_Inflector.singularRules,_Inflector.uncountableWords,i)},camelize:function(e,i){const n=e.split("/");for(let s=0;s<n.length;s++){const o=n[s].split("_"),r=i&&s+1===n.length?1:0;for(let t=r;t<o.length;t++)o[t]=o[t].charAt(0).toUpperCase()+o[t].substring(1);n[s]=o.join("")}if(e=n.join("::"),i){const s=e.charAt(0).toLowerCase(),o=e.slice(1);e=s+o}return e},underscore:function(e){const i=e.split("::");for(let n=0;n<i.length;n++)i[n]=i[n].replace(_Inflector.uppercase,"_$1"),i[n]=i[n].replace(_Inflector.underbarPrefix,"");return e=i.join("/").toLowerCase(),e},humanize:function(e,i){return e=e.toLowerCase(),e=e.replace(_Inflector.idSuffix,""),e=e.replace(_Inflector.underbar," "),i||(e=_Inflector.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(_Inflector.spaceOrUnderbar,"-"),e},camel2words:function(e,i){i?(e=_Inflector.camelize(e),e=_Inflector.underscore(e)):e=e.toLowerCase(),e=e.replace(_Inflector.underbar," ");const n=e.split(" ");for(let s=0;s<n.length;s++){const o=n[s].split("-");for(let r=0;r<o.length;r++)_Inflector.nonTitlecasedWords.includes(o[r].toLowerCase())||(o[r]=_Inflector.capitalize(o[r]));n[s]=o.join("-")}return e=n.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){const i=e.split("::");return e=i[i.length-1],e},tableize:function(e){return e=_Inflector.pluralize(_Inflector.underscore(e)),e},classify:function(e){return e=_Inflector.singularize(_Inflector.camelize(e)),e},foreignKey:function(e,i){return e=_Inflector.underscore(_Inflector.demodulize(e))+(i?"":"_")+"id",e},ordinalize:function(e){const i=e.split(" ");for(let n=0;n<i.length;n++){const s=parseInt(i[n]);if(Number.isNaN(s)){const o=i[n].substring(i[n].length-2),r=i[n].substring(i[n].length-1);let t="th";o!=="11"&&o!=="12"&&o!=="13"&&(r==="1"?t="st":r==="2"?t="nd":r==="3"&&(t="rd")),i[n]+=t}}return e=i.join(" "),e}};exports.default=_Inflector;
@@ -1,2 +0,0 @@
1
- declare const denormalize: (response: any) => any;
2
- export { denormalize };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.denormalize=void 0;const findIncluded=(e,i)=>i.find(t=>e.id===t.id&&e.type===t.type),denormalizeResource=(e,i)=>{const t=Object.assign({id:e.id,type:e.type},e.attributes);return e.relationships&&Object.keys(e.relationships).forEach(r=>{const a=e.relationships[r].data;a?Array.isArray(a)?t[r]=a.map(n=>denormalizeResource(findIncluded(n,i),i)):t[r]=denormalizeResource(findIncluded(a,i),i):a===null&&(t[r]=null)}),t},denormalize=e=>{let i;e.links&&delete e.links;const t=e.data,r=e.included;return Array.isArray(t)?i=t.map(a=>denormalizeResource(a,r)):i=denormalizeResource(t,r),i};exports.denormalize=denormalize;
@@ -1,28 +0,0 @@
1
- /** Print a formatted object */
2
- declare const printObject: (obj: any, options?: {
3
- color?: boolean;
4
- sort?: boolean;
5
- width?: number;
6
- }) => string;
7
- /** Print object in JSON format */
8
- declare const printJSON: (obj: any, options?: {
9
- unformatted?: boolean;
10
- tabSize?: number;
11
- }) => string;
12
- /** Print object in CSV format */
13
- declare const printCSV: (obj: object[], flags?: any) => string;
14
- /** Center a string in the given width space */
15
- declare const center: (str: string, width: number) => string;
16
- /** Compute longest string in a list of strings */
17
- declare const maxLength: (values: any[], field: string) => number;
18
- /** Clean ISO string date */
19
- declare const cleanDate: (date: string) => string;
20
- /** Localized string date */
21
- declare const localeDate: (date: string) => string;
22
- /** Format aoutput */
23
- declare const formatOutput: (output: any, flags?: any, { color }?: {
24
- color?: boolean | undefined;
25
- }) => string;
26
- /** Format error message */
27
- declare const formatError: (error: any, flags?: any) => string;
28
- export { printObject, printJSON, printCSV, center, maxLength, cleanDate, localeDate, formatOutput, formatError };
package/lib/cjs/output.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatError=exports.formatOutput=exports.localeDate=exports.cleanDate=exports.maxLength=exports.center=exports.printCSV=exports.printJSON=exports.printObject=void 0;const util_1=require("util"),printObject=(r,e)=>(0,util_1.inspect)(r,{showHidden:!1,depth:null,colors:e?.color===void 0?!0:e.color,sorted:e?.sort===void 0?!1:e?.sort,maxArrayLength:1/0,breakLength:e?.width||120});exports.printObject=printObject;const printJSON=(r,e)=>JSON.stringify(r,null,e?.unformatted?void 0:e?.tabSize||4);exports.printJSON=printJSON;const printCSV=(r,e)=>{if(!r||r.length===0)return"";const n=Object.keys(r[0]).filter(t=>["id","type"].includes(t)?e?.fields.includes(t):!0);let l=n.map(t=>t.toUpperCase().replace(/_/g," ")).join(";")+`
2
- `;return r.forEach(t=>{l+=n.map(a=>t[a]).join(";")+`
3
- `}),l};exports.printCSV=printCSV;const center=(r,e)=>r.padStart(r.length+Math.floor((e-r.length)/2)," ").padEnd(e," ");exports.center=center;const maxLength=(r,e)=>r.reduce((n,l)=>{const t=Array.isArray(l[e])?l[e].join():l[e];return Math.max(n,String(t).length)},0);exports.maxLength=maxLength;const cleanDate=r=>r.replace("T"," ").replace("Z","").substring(0,r.lastIndexOf("."));exports.cleanDate=cleanDate;const localeDate=r=>r?new Date(Date.parse(r)).toLocaleString():"";exports.localeDate=localeDate;const formatOutput=(r,e,{color:n=!0}={})=>{if(!r)return"";if(typeof r=="string")return r;if(e){if(e.csv)return printCSV(r,e);if(e.json)return printJSON(r,{unformatted:e.unformatted})}return printObject(r,{color:n})};exports.formatOutput=formatOutput;const formatError=(r,e)=>formatOutput(r.errors||r,e);exports.formatError=formatError;
package/lib/cjs/raw.d.ts DELETED
@@ -1,12 +0,0 @@
1
- declare const rawRequest: (config: {
2
- baseUrl: string;
3
- resource: string;
4
- accessToken: string;
5
- operation: Operation;
6
- }, data: any, id?: string) => Promise<any>;
7
- declare const readDataFile: (file: string) => any;
8
- declare enum Operation {
9
- Create = "POST",
10
- Update = "PATCH"
11
- }
12
- export { readDataFile, rawRequest, Operation };
package/lib/cjs/raw.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Operation=exports.rawRequest=exports.readDataFile=void 0;const axios_1=__importDefault(require("axios")),fs_1=require("fs"),_1=require("."),rawRequest=async(e,t,r)=>await axios_1.default.request({method:e.operation,baseURL:e.baseUrl,url:`/api/${e.resource}`+(r?`/${r}`:""),headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},data:t}).then(a=>a.data);exports.rawRequest=rawRequest;const readDataFile=e=>{let t,r;try{t=(0,fs_1.readFileSync)(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${_1.clColor.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${_1.clColor.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}};exports.readDataFile=readDataFile;var Operation;(function(e){e.Create="POST",e.Update="PATCH"})(Operation||(exports.Operation=Operation={}));
@@ -1,2 +0,0 @@
1
- declare const downloadSchema: (version?: string) => Promise<any>;
2
- export { downloadSchema as download };
package/lib/cjs/schema.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.download=void 0;const axios_1=__importDefault(require("axios")),config_1=__importDefault(require("./config")),downloadSchema=async e=>{const a=`https://data.${config_1.default.api.default_app_domain}/schemas/`,t=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,s=a+t;return(await axios_1.default.get(s)).data};exports.download=downloadSchema;
@@ -1,14 +0,0 @@
1
- export declare const red: (txt: unknown) => string;
2
- export declare const green: (txt: unknown) => string;
3
- export declare const yellow: (txt: unknown) => string;
4
- export declare const blue: (txt: unknown) => string;
5
- export declare const cyan: (txt: unknown) => string;
6
- export declare const magenta: (txt: unknown) => string;
7
- export declare const slug: (txt: unknown) => string;
8
- export declare const id: (txt: unknown) => string;
9
- export declare const command: (txt: unknown) => string;
10
- export declare const flag: (txt: unknown) => string;
11
- export declare const error: (txt: unknown) => string;
12
- export declare const success: (txt: unknown) => string;
13
- export declare const warning: (txt: unknown) => string;
14
- export declare const highlight: (txt: unknown) => string;
package/lib/cjs/style.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.highlight=exports.warning=exports.success=exports.error=exports.flag=exports.command=exports.id=exports.slug=exports.magenta=exports.cyan=exports.blue=exports.yellow=exports.green=exports.red=void 0;const chalk_1=__importDefault(require("chalk")),red=e=>chalk_1.default.red(e);exports.red=red;const green=e=>chalk_1.default.green(e);exports.green=green;const yellow=e=>chalk_1.default.yellow(e);exports.yellow=yellow;const blue=e=>chalk_1.default.blue(e);exports.blue=blue;const cyan=e=>chalk_1.default.cyan(e);exports.cyan=cyan;const magenta=e=>chalk_1.default.magenta(e);exports.magenta=magenta;const slug=e=>chalk_1.default.yellowBright(e);exports.slug=slug;const id=e=>chalk_1.default.magenta.bold(e);exports.id=id;const command=e=>chalk_1.default.cyan.italic(e);exports.command=command;const flag=e=>chalk_1.default.magenta.italic(e);exports.flag=flag;const error=e=>chalk_1.default.red(e);exports.error=error;const success=e=>chalk_1.default.green(e);exports.success=success;const warning=e=>chalk_1.default.yellow(e);exports.warning=warning;const highlight=e=>chalk_1.default.yellowBright(e);exports.highlight=highlight;
@@ -1,2 +0,0 @@
1
- declare const symbols: Record<string, Record<string, string>>;
2
- export { symbols };
package/lib/cjs/symbol.js DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.symbols=void 0;const symbols={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};exports.symbols=symbols,symbols.check.heavy=symbols.check.small,symbols.check.whiteHeavy=symbols.check.bkgGreen,symbols.cross.heavyBallot=symbols.cross.small;
package/lib/cjs/text.d.ts DELETED
@@ -1,6 +0,0 @@
1
- declare const capitalize: (str: string | undefined) => string | undefined;
2
- declare const pluralize: (str: string, plural?: string | undefined) => string;
3
- declare const singularize: (str: string, singular?: string | undefined) => string;
4
- declare const camelize: (str: string, lowFirstLetter?: boolean | undefined) => string;
5
- export { capitalize, pluralize, singularize, camelize };
6
- export { symbols } from './symbol';
package/lib/cjs/text.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.symbols=exports.camelize=exports.singularize=exports.pluralize=exports.capitalize=void 0;const inflector_1=__importDefault(require("./inflector")),capitalize=e=>{if(!e)return e;let t=e.toLowerCase();return t=t.substring(0,1).toUpperCase()+t.substring(1),t};exports.capitalize=capitalize;const pluralize=inflector_1.default.pluralize;exports.pluralize=pluralize;const singularize=inflector_1.default.singularize;exports.singularize=singularize;const camelize=inflector_1.default.camelize;exports.camelize=camelize;var symbol_1=require("./symbol");Object.defineProperty(exports,"symbols",{enumerable:!0,get:function(){return symbol_1.symbols}});
@@ -1,58 +0,0 @@
1
- import { type AppAuth } from './application';
2
- import { type ApiMode } from './api';
3
- export type AuthScope = string | string[];
4
- export type AccessToken = {
5
- accessToken: string;
6
- tokenType: 'bearer' | 'Bearer';
7
- expiresIn: number;
8
- expires: Date;
9
- scope: AuthScope;
10
- createdAt: number;
11
- error?: string;
12
- errorDescription?: string;
13
- };
14
- export type AccessTokenInfo = {
15
- organization?: {
16
- id: string;
17
- slug: string;
18
- };
19
- application: {
20
- id: string;
21
- kind: 'integration' | 'sales_channel' | 'user';
22
- public: boolean;
23
- };
24
- test: boolean;
25
- exp?: number;
26
- rand?: number;
27
- owner?: {
28
- id: string;
29
- type: 'Customer' | 'User';
30
- };
31
- market?: {
32
- id: string[];
33
- price_list_id: string;
34
- stock_location_ids?: string[];
35
- geocoder_id?: string;
36
- allows_external_prices: boolean;
37
- };
38
- scope?: AuthScope;
39
- user?: {
40
- id: string;
41
- };
42
- };
43
- export type CustomToken = {
44
- accessToken: string;
45
- info: AccessTokenInfo;
46
- expMinutes: number;
47
- };
48
- /** Decode a Commerce Layer access token */
49
- declare const decodeAccessToken: (accessToken: string) => AccessTokenInfo;
50
- /** generate a custom access token */
51
- declare const generateAccessToken: (token: AccessTokenInfo, sharedSecret: string, minutes: number) => CustomToken;
52
- declare const getAccessToken: (auth: AppAuth) => Promise<AccessToken>;
53
- declare const revokeAccessToken: (app: AppAuth, token: string, logger?: {
54
- log: (msg: any) => void;
55
- } | undefined) => Promise<void>;
56
- declare const isAccessTokenExpiring: (tokenData: AccessToken) => boolean;
57
- declare const getTokenEnvironment: (token: string | AccessTokenInfo) => ApiMode;
58
- export { decodeAccessToken, generateAccessToken, getAccessToken, revokeAccessToken, isAccessTokenExpiring, getTokenEnvironment };
package/lib/cjs/token.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,o){o===void 0&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){o===void 0&&(o=n),e[o]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&__createBinding(t,e,n);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getTokenEnvironment=exports.isAccessTokenExpiring=exports.revokeAccessToken=exports.getAccessToken=exports.generateAccessToken=exports.decodeAccessToken=void 0;const jsonwebtoken_1=__importDefault(require("jsonwebtoken")),config_1=__importDefault(require("./config")),https_1=__importDefault(require("https")),application_1=require("./application"),util_1=require("./util"),api_1=require("./api"),errors_1=require("@oclif/core/lib/errors"),js_auth_1=__importStar(require("@commercelayer/js-auth")),decodeAccessToken=e=>{const t=jsonwebtoken_1.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t};exports.decodeAccessToken=decodeAccessToken;const generateAccessToken=(e,t,n)=>{const r=Object.assign(Object.assign({},e),{exp:Math.floor(Date.now()/1e3)+n*60,rand:Math.random()}),i=config_1.default.api.token_encoding_algorithm,c=jsonwebtoken_1.default.sign(r,t,{algorithm:i,noTimestamp:!0}),a=jsonwebtoken_1.default.verify(c,t,{algorithms:[i]});return{accessToken:c,info:a,expMinutes:n}};exports.generateAccessToken=generateAccessToken;const getAccessToken=async e=>{let t;if((0,application_1.isProvisioningApp)(e))t=await getAccessTokenProvisioning(e);else{const n=e.scope?Array.isArray(e.scope)?e.scope.map(r=>r.trim()).join(","):e.scope:"",o={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:n};e.email&&e.password?(o.username=e.email,o.password=e.password,t=await(0,js_auth_1.default)("password",o)):t=await(0,js_auth_1.default)("client_credentials",o)}if(t){if(t.error)throw new Error(`Unable to get access token: ${t.error}`)}else throw new Error("Unable to get access token");return t};exports.getAccessToken=getAccessToken;const getAccessTokenProvisioning=async e=>{const t={clientId:e.clientId,clientSecret:e.clientSecret,domain:e.domain};return js_auth_1.provisioning.authentication(t)},revokeAccessToken=async(e,t,n)=>{const o=Array.isArray(e.scope)?e.scope.join(";"):e.scope,r=JSON.stringify({grant_type:"client_credentials",client_id:e.clientId,client_secret:e.clientSecret,scope:o,token:t}),i=(0,application_1.isProvisioningApp)(e),c=i?"application/vnd.api+json":"application/json",a=i?"auth":e.slug||"",p={hostname:(0,api_1.baseURL)(a,e.domain).replace("https://","").replace("http://",""),port:443,path:"/oauth/revoke",method:"POST",headers:{"Content-Type":c,"Content-Length":r.length}};n&&n.log(p),n&&n.log(r);let l=!1;try{const s=https_1.default.request(p);s.on("error",d=>{throw l=!0,new errors_1.CLIError(d.message||"Error revoking access token")}),s.write(r),s.end()}catch(s){throw l=!0,n&&n.log(s.message),s instanceof errors_1.CLIError?s:new errors_1.CLIError(s.message||"Error revoking access token")}await(0,util_1.sleep)(300),!l&&n&&n.log("Access token revoked")};exports.revokeAccessToken=revokeAccessToken;const isAccessTokenExpiring=e=>{const n=Math.floor(Date.now()/1e3),o=Math.floor(new Date(e.expires).getTime()/1e3);return n>=o-30};exports.isAccessTokenExpiring=isAccessTokenExpiring;const getTokenEnvironment=e=>(typeof e=="string"?decodeAccessToken(e):e).test?"test":"live";exports.getTokenEnvironment=getTokenEnvironment;
@@ -1,7 +0,0 @@
1
- interface Package {
2
- name: string;
3
- version: string;
4
- description: string;
5
- }
6
- declare const checkUpdate: (pkg: Package) => void;
7
- export { checkUpdate, type Package };
package/lib/cjs/update.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkUpdate=void 0;const chalk_1=__importDefault(require("chalk")),update_notifier_cjs_1=__importDefault(require("update-notifier-cjs")),UPDATE_CHECK_INTERVAL_HOURS=1,checkUpdate=e=>{const t=(0,update_notifier_cjs_1.default)({pkg:e,updateCheckInterval:36e5*UPDATE_CHECK_INTERVAL_HOURS});if(t.update){const a="commercelayer plugins:update";t.notify({isGlobal:!1,message:`-= ${chalk_1.default.bgWhite.black.bold(` ${e.description} `)} =-
2
-
3
- New version available: ${chalk_1.default.dim("{currentVersion}")} -> ${chalk_1.default.green("{latestVersion}")}
4
- Run ${chalk_1.default.cyanBright(a)} to update`})}};exports.checkUpdate=checkUpdate;
package/lib/cjs/util.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { Config } from '@oclif/core/lib/interfaces';
2
- /** Await ms milliseconds */
3
- declare const sleep: (ms: number) => Promise<void>;
4
- declare const resetConsole: () => void;
5
- declare const log: (message?: string, ...args: unknown[]) => void;
6
- declare const specialFolder: (filePath: string, createIfNotExists?: boolean) => string;
7
- declare const generateGroupUID: () => string;
8
- declare const userAgent: (config: Config) => string;
9
- export { sleep, resetConsole, log, specialFolder, generateGroupUID, userAgent };
package/lib/cjs/util.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.userAgent=exports.generateGroupUID=exports.specialFolder=exports.log=exports.resetConsole=exports.sleep=void 0;const util_1=require("util"),path_1=require("path"),os_1=require("os"),fs_1=require("fs"),sleep=async e=>new Promise(t=>setTimeout(t,e));exports.sleep=sleep;const resetConsole=()=>{const e="\x1B[?25h",t="\x1B[?7h";process.stdout.write(`${e}${t}`)};exports.resetConsole=resetConsole;const log=(e="",...t)=>{e=typeof e=="string"?e:(0,util_1.inspect)(e),process.stdout.write((0,util_1.format)(e,...t)+`
2
- `)};exports.log=log;const specialFolder=(e,t=!1)=>{const o=["desktop","home"],r=e.toLowerCase().split(/[\\\/]/g)[0];if(o.includes(r)){let n=(0,os_1.homedir)();r==="desktop"&&(n+=`${path_1.sep}Desktop`),e=e.replace(r,n)}const s=(0,path_1.dirname)(e);return t&&!(0,fs_1.existsSync)(s)&&(0,fs_1.mkdirSync)(s,{recursive:!0}),e};exports.specialFolder=specialFolder;const generateGroupUID=()=>{const e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),o=("000"+e.toString(36)).slice(-3),r=("000"+t.toString(36)).slice(-3);return o+r};exports.generateGroupUID=generateGroupUID;const userAgent=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;exports.userAgent=userAgent;
package/lib/esm/api.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import type { Method } from 'axios';
2
- import { rawRequest, readDataFile, Operation } from './raw';
3
- import { denormalize } from './jsonapi';
4
- type ApiMode = 'test' | 'live';
5
- type ApiType = 'core' | 'provisioning' | 'metrics';
6
- export type { ApiMode, ApiType };
7
- /** Build base URL */
8
- declare const baseURL: (slug?: string, domain?: string, provisioning?: boolean) => string;
9
- /** Extract domain name from URL */
10
- declare const extractDomain: (baseUrl: string) => string | undefined;
11
- /** Decode API execution mode */
12
- declare const execMode: (liveFlag: string | boolean | undefined) => ApiMode;
13
- declare const humanizeResource: (type: string) => string;
14
- export { baseURL, extractDomain, execMode, humanizeResource };
15
- export declare const isResourceCacheable: (resource?: string, method?: Method) => boolean;
16
- export type DelayOptions = {
17
- environment?: ApiMode;
18
- parallelRequests?: number;
19
- totalRequests?: number;
20
- minimumDelay?: number;
21
- securityDelay?: number;
22
- resourceType?: string;
23
- method?: Method;
24
- };
25
- export declare const liveEnvironment: (env: ApiMode) => boolean;
26
- export declare const requestRateLimitDelay: (options?: DelayOptions) => number;
27
- export { rawRequest as requestRaw, readDataFile as requestDataFile, Operation };
28
- export { denormalize as responseDenormalize };
29
- export declare const request: {
30
- raw: (config: {
31
- baseUrl: string;
32
- resource: string;
33
- accessToken: string;
34
- operation: Operation;
35
- }, data: any, id?: string | undefined) => Promise<any>;
36
- readDataFile: (file: string) => any;
37
- rateLimitDelay: (options?: DelayOptions) => number;
38
- };
39
- export declare const response: {
40
- denormalize: (response: any) => any;
41
- };
package/lib/esm/api.js DELETED
@@ -1 +0,0 @@
1
- import s from"./config";import{rawRequest as _,readDataFile as c,Operation as p}from"./raw";import{denormalize as d}from"./jsonapi";const q=(e,r,u)=>`https://${(u?"provisioning":e||"").toLowerCase()}.${r||s.api.default_domain}`,f=e=>{if(e)return e.substring(e.indexOf(".")+1)},g=e=>e===!0||e==="live"?"live":"test",b=e=>e.replace(/_/g," ");export{q as baseURL,f as extractDomain,g as execMode,b as humanizeResource};const y=["bundles","imports","markets","prices","price_lists","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"];export const isResourceCacheable=(e,r)=>y.includes(e||"")&&(r||"get").toLowerCase()==="get",liveEnvironment=e=>e==="live",requestRateLimitDelay=e=>{const r=e?.environment||"test",u=e?.parallelRequests||1,a=isResourceCacheable(e?.resourceType,e?.method);let i=a?s.api.requests_max_num_burst_cacheable:s.api.requests_max_num_burst,n=a?s.api.requests_max_num_avg_cacheable:s.api.requests_max_num_avg;r!=="live"&&(i=a?s.api.requests_max_num_burst_test_cacheable:s.api.requests_max_num_burst_test,n=a?s.api.requests_max_num_avg_test_cacheable:s.api.requests_max_num_avg_test);const v=s.api.requests_max_secs_burst/i,x=s.api.requests_max_secs_avg/n,l=u*v,m=u*x,o=e?.totalRequests;let t=0;return o?o>i&&(o>n?t=m:t=l):t=Math.max(l,m),t=t*1e3,e?.minimumDelay&&(t=Math.max(e.minimumDelay,t)),e?.securityDelay&&(t+=e.securityDelay),t=Math.ceil(t),t};export{_ as requestRaw,c as requestDataFile,p as Operation};export{d as responseDenormalize};export const request={raw:_,readDataFile:c,rateLimitDelay:requestRateLimitDelay},response={denormalize:d};
@@ -1,34 +0,0 @@
1
- import type { ApiMode, ApiType } from "./api";
2
- import type { AuthScope } from "./token";
3
- interface AppKey {
4
- key: string;
5
- mode: ApiMode;
6
- id?: string;
7
- alias?: string;
8
- }
9
- interface AppAuth {
10
- slug?: string;
11
- domain?: string;
12
- clientId: string;
13
- clientSecret?: string;
14
- scope?: AuthScope;
15
- email?: string;
16
- password?: string;
17
- api?: ApiType;
18
- }
19
- interface AppInfo extends AppKey, AppAuth {
20
- organization?: string;
21
- kind: string;
22
- name: string;
23
- baseUrl?: string;
24
- }
25
- export type { AppKey, AppAuth, AppInfo };
26
- /** Build application key */
27
- declare const appKey: () => string;
28
- /** Check application key */
29
- declare const appKeyValid: (appKey: AppKey) => boolean;
30
- /** Check if two application keys are equal */
31
- declare const appKeyMatch: (app1?: AppKey, app2?: AppKey) => boolean;
32
- declare const arrayScope: (scope?: AuthScope) => string[];
33
- declare const isProvisioningApp: (app: AppAuth) => boolean;
34
- export { appKey, appKeyValid, appKeyMatch, arrayScope, isProvisioningApp };
@@ -1 +0,0 @@
1
- import t from"./config";const s=()=>Date.now().toString(36),c=n=>n.key!==void 0&&n.key!=="",u=(n,e)=>{const r=n!==void 0,o=e!==void 0;return!r&&!o||r&&o&&n.key===e.key},i=n=>n?Array.isArray(n)?n:[n]:[],a=n=>i(n.scope).includes(t.provisioning.scope)||n.api==="provisioning";export{s as appKey,c as appKeyValid,u as appKeyMatch,i as arrayScope,a as isProvisioningApp};
@@ -1,107 +0,0 @@
1
- import chalk from 'chalk';
2
- import type { ApiMode } from './api';
3
- export declare const reset: chalk.Chalk;
4
- export declare const visible: chalk.Chalk;
5
- export declare const hidden: chalk.Chalk;
6
- export declare const red: chalk.Chalk;
7
- export declare const redBright: chalk.Chalk;
8
- export declare const green: chalk.Chalk;
9
- export declare const greenBright: chalk.Chalk;
10
- export declare const yellow: chalk.Chalk;
11
- export declare const yellowBright: chalk.Chalk;
12
- export declare const blue: chalk.Chalk;
13
- export declare const blueBright: chalk.Chalk;
14
- export declare const white: chalk.Chalk;
15
- export declare const whiteBright: chalk.Chalk;
16
- export declare const black: chalk.Chalk;
17
- export declare const blackBright: chalk.Chalk;
18
- export declare const grey: chalk.Chalk;
19
- export declare const cyan: chalk.Chalk;
20
- export declare const cyanBright: chalk.Chalk;
21
- export declare const magenta: chalk.Chalk;
22
- export declare const magentaBright: chalk.Chalk;
23
- export declare const bold: chalk.Chalk;
24
- export declare const dim: chalk.Chalk;
25
- export declare const underline: chalk.Chalk;
26
- export declare const italic: chalk.Chalk;
27
- export declare const bg: {
28
- white: chalk.Chalk;
29
- whiteBright: chalk.Chalk;
30
- black: chalk.Chalk;
31
- blackBright: chalk.Chalk;
32
- grey: chalk.Chalk;
33
- red: chalk.Chalk;
34
- redBright: chalk.Chalk;
35
- green: chalk.Chalk;
36
- greenBright: chalk.Chalk;
37
- yellow: chalk.Chalk;
38
- yellowBright: chalk.Chalk;
39
- blue: chalk.Chalk;
40
- blueBright: chalk.Chalk;
41
- magenta: chalk.Chalk;
42
- magentaBright: chalk.Chalk;
43
- cyan: chalk.Chalk;
44
- cyanBright: chalk.Chalk;
45
- };
46
- export declare const style: {
47
- organization: chalk.Chalk;
48
- application: chalk.Chalk;
49
- slug: chalk.Chalk;
50
- id: chalk.Chalk;
51
- token: chalk.Chalk;
52
- resource: chalk.Chalk;
53
- attribute: chalk.Chalk;
54
- trigger: chalk.Chalk;
55
- kind: chalk.Chalk;
56
- live: chalk.Chalk;
57
- test: chalk.Chalk;
58
- execMode: (mode: ApiMode) => chalk.Chalk;
59
- success: chalk.Chalk;
60
- warning: chalk.Chalk;
61
- error: chalk.Chalk;
62
- arg: chalk.Chalk;
63
- flag: chalk.Chalk;
64
- command: chalk.Chalk;
65
- value: chalk.Chalk;
66
- alias: chalk.Chalk;
67
- plugin: chalk.Chalk;
68
- title: chalk.Chalk;
69
- path: chalk.Chalk;
70
- datetime: chalk.Chalk;
71
- number: chalk.Chalk;
72
- };
73
- export declare const type: {
74
- datetime: chalk.Chalk;
75
- number: chalk.Chalk;
76
- path: chalk.Chalk;
77
- };
78
- export declare const api: {
79
- organization: chalk.Chalk;
80
- application: chalk.Chalk;
81
- slug: chalk.Chalk;
82
- id: chalk.Chalk;
83
- token: chalk.Chalk;
84
- resource: chalk.Chalk;
85
- attribute: chalk.Chalk;
86
- trigger: chalk.Chalk;
87
- kind: chalk.Chalk;
88
- live: chalk.Chalk;
89
- test: chalk.Chalk;
90
- };
91
- export declare const msg: {
92
- success: chalk.Chalk;
93
- warning: chalk.Chalk;
94
- error: chalk.Chalk;
95
- };
96
- export declare const cli: {
97
- arg: chalk.Chalk;
98
- flag: chalk.Chalk;
99
- command: chalk.Chalk;
100
- value: chalk.Chalk;
101
- alias: chalk.Chalk;
102
- plugin: chalk.Chalk;
103
- };
104
- export declare const table: {
105
- header: chalk.Chalk;
106
- key: chalk.Chalk;
107
- };
package/lib/esm/color.js DELETED
@@ -1 +0,0 @@
1
- import t from"chalk";export const reset=t.reset,visible=t.visible,hidden=t.hidden,red=t.red,redBright=t.redBright,green=t.green,greenBright=t.greenBright,yellow=t.yellow,yellowBright=t.yellowBright,blue=t.blue,blueBright=t.blueBright,white=t.white,whiteBright=t.whiteBright,black=t.black,blackBright=t.blackBright,grey=t.grey,cyan=t.cyan,cyanBright=t.cyanBright,magenta=t.magenta,magentaBright=t.magentaBright,bold=t.bold,dim=t.dim,underline=t.underline,italic=t.italic,bg={white:t.bgWhite,whiteBright:t.bgWhiteBright,black:t.bgBlack,blackBright:t.bgBlackBright,grey:t.bgGrey,red:t.bgRed,redBright:t.bgRedBright,green:t.bgGreen,greenBright:t.bgGreenBright,yellow:t.bgYellow,yellowBright:t.bgYellowBright,blue:t.bgBlue,blueBright:t.bgBlueBright,magenta:t.bgMagenta,magentaBright:t.bgMagentaBright,cyan:t.bgCyan,cyanBright:t.bgCyanBright},style={organization:yellowBright.bold,application:yellowBright.bold,slug:yellowBright,id:bold,token:blueBright,resource:bold,attribute:italic,trigger:cyanBright,kind:cyanBright,live:greenBright,test:yellowBright,execMode:e=>e==="live"?style.live:style.test,success:greenBright,warning:yellowBright,error:redBright,arg:italic,flag:italic,command:italic,value:italic,alias:cyanBright,plugin:blueBright,title:blueBright,path:italic,datetime:cyanBright,number:yellowBright},type={datetime:style.datetime,number:style.number,path:style.path},api={organization:style.organization,application:style.application,slug:style.slug,id:style.id,token:style.token,resource:style.resource,attribute:style.attribute,trigger:style.trigger,kind:style.kind,live:style.live,test:style.test},msg={success:style.success,warning:style.warning,error:style.error},cli={arg:style.arg,flag:style.flag,command:style.command,value:style.value,alias:style.alias,plugin:style.plugin},table={header:yellowBright.bold,key:blueBright};
@@ -1,21 +0,0 @@
1
- /** Copy command flags excluding a subset */
2
- declare const commandFlags: <T extends object>(flags: T, exclude?: string[]) => T;
3
- export { commandFlags };
4
- export type KeyVal = Record<string, string | number | boolean | undefined | null>;
5
- export type KeyValString = Record<string, string>;
6
- export type KeyValArray = Record<string, string[]>;
7
- export type KeyValRel = Record<string, {
8
- readonly type: string;
9
- readonly id: string;
10
- }>;
11
- export type KeyValObj = Record<string, any>;
12
- export type KeyValSort = Record<string, 'asc' | 'desc'>;
13
- export type ResAttributes = KeyValObj;
14
- declare const fixValueType: (val: string) => string | number | boolean | null | undefined;
15
- declare const findLongStringFlag: (args: string[], name: string) => {
16
- value: string;
17
- index: number;
18
- single: boolean;
19
- } | undefined;
20
- declare const fixDashedFlagValue: (argv: string[], flag: any, name?: string, parsed?: any) => string[];
21
- export { fixValueType, findLongStringFlag, fixDashedFlagValue };
@@ -1 +0,0 @@
1
- const F=(e,t)=>{const c=Object.assign({},e);if(t)for(const n of t)delete c[n];return c};export{F as commandFlags};const _=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},$=(e,t)=>{const c=t.startsWith("--")?t:`--${t}`;let n;const i=e.findIndex(r=>r.startsWith(c));let l=!1;if(i>-1){const r=e[i];if(r.includes("=")){const a=r.split("=");n=a.length===2?a[1]:"",l=!0}else n=e[i+1];return{value:n,index:i,single:l}}else return},b=(e,t,c,n)=>{const i="____",l=t.name||c,r=t.char;if(!l&&!r)return e;const a=l?l.startsWith("--")?l:`--${l}`:void 0,u=r?t.char.startsWith("-")?r:`-${r}`:void 0;let d=e.findIndex(o=>u&&o.startsWith(u)||a&&o.startsWith(a));if(d<0)return e;let f=e[d],s="",g="";if(u&&f.startsWith(u))s=f.replace(u,"").trim(),f=u;else if(a&&f.startsWith(a))s=f.replace(a,"").trim(),f=a;else return e;if(s.startsWith("=")?(s=s.slice(1),g=f+"="):s||(s=e[++d]),s.startsWith("-")||s.startsWith(i)){const o=s.startsWith(`${i}`)?s.replace(`${i}`,""):s.replace("-",`${i}-`);if(e[d]=g+o,s.startsWith(i)&&n){const h=l?l.replace("--",""):void 0,W=Object.entries(n.flags).find(([x,m])=>m===s);W&&(!h||h===W[0])&&(n.flags[W[0]]=o);const p=Object.values(n.raw).find(x=>x.type==="flag"&&x.input===s);p&&(!h||h===p.flag)&&(p.input=o)}}return e};export{_ as fixValueType,$ as findLongStringFlag,b as fixDashedFlagValue};
@@ -1,92 +0,0 @@
1
- type ApiConfig = {
2
- default_domain: string;
3
- default_app_domain: string;
4
- default_stg_domain: string;
5
- token_expiration_mins: number;
6
- token_encoding_algorithm: string;
7
- requests_max_num_burst: number;
8
- requests_max_num_burst_cacheable: number;
9
- requests_max_num_burst_test: number;
10
- requests_max_num_burst_test_cacheable: number;
11
- requests_max_secs_burst: number;
12
- requests_max_num_avg: number;
13
- requests_max_num_avg_cacheable: number;
14
- requests_max_num_avg_test: number;
15
- requests_max_num_avg_test_cacheable: number;
16
- requests_max_secs_avg: number;
17
- requests_max_num_oauth: number;
18
- requests_max_secs_oauth: number;
19
- page_max_size: number;
20
- page_default_size: number;
21
- };
22
- type ApplicationConfig = {
23
- kinds: readonly string[];
24
- login_scopes: readonly string[];
25
- };
26
- type ImportsConfig = {
27
- max_size: number;
28
- statuses: readonly string[];
29
- types: readonly string[];
30
- max_queue_length: number;
31
- attachment_expiration: number;
32
- };
33
- type ExportsConfig = {
34
- max_size: number;
35
- statuses: readonly string[];
36
- types: readonly string[];
37
- max_queue_length: number;
38
- attachment_expiration: number;
39
- };
40
- type CleanupsConfig = {
41
- max_size: number;
42
- statuses: readonly string[];
43
- types: readonly string[];
44
- max_queue_length: number;
45
- };
46
- type WebhooksConfig = {
47
- retry_number: number;
48
- };
49
- type CliConfig = {
50
- applications: readonly string[];
51
- };
52
- type DocConfig = {
53
- core: string;
54
- core_api_reference: string;
55
- core_how_tos: string;
56
- core_raste_limits: string;
57
- core_filtering_data: string;
58
- metrics: string;
59
- metrics_api_reference: string;
60
- provisioning: string;
61
- provisioning_api_reference: string;
62
- imports_resources: string;
63
- exports_resources: string;
64
- cleanups_resources: string;
65
- webhooks_events: string;
66
- tags_resources: string;
67
- };
68
- type TagsConfig = {
69
- max_resource_tags: number;
70
- taggable_resources: readonly string[];
71
- tag_name_max_length: number;
72
- tag_name_pattern: RegExp;
73
- };
74
- type ProvisioningConfig = {
75
- default_subdomain: string;
76
- scope: string;
77
- applications: readonly string[];
78
- };
79
- type Config = {
80
- api: ApiConfig;
81
- application: ApplicationConfig;
82
- imports: ImportsConfig;
83
- exports: ExportsConfig;
84
- cleanups: CleanupsConfig;
85
- webhooks: WebhooksConfig;
86
- cli: CliConfig;
87
- doc: DocConfig;
88
- tags: TagsConfig;
89
- provisioning: ProvisioningConfig;
90
- };
91
- declare const config: Config;
92
- export default config;
package/lib/esm/config.js DELETED
@@ -1 +0,0 @@
1
- const s=["in_progress","pending","completed","interrupted"],t=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","tags","tax_categories"],r=["addresses","bundles","coupons","customer_subscriptions","customers","gift_cards","line_items","orders","payment_methods","price_tiers","prices","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","tax_categories","transactions","authorizations","captures","voids","refunds"],_=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],i=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],e={erl_oauth_limit_live:30,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500},o={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",requests_max_num_burst:e.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:e.erl_burst_limit_cachable_live,requests_max_num_burst_test:e.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:e.erl_burst_limit_cachable_test,requests_max_num_avg:e.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:e.erl_average_limit_cachable_live,requests_max_num_avg_test:e.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:e.erl_average_limit_cachable_test,requests_max_num_oauth:e.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location"]},imports:{max_size:5e3,statuses:s,types:t,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:s,types:r,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:s,types:_,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources"},tags:{max_resource_tags:10,taggable_resources:i,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]}};export default o;
@@ -1,10 +0,0 @@
1
- declare const documentation: string;
2
- interface Filter extends Record<string, unknown> {
3
- predicate: string;
4
- description: string;
5
- }
6
- declare const filterList: () => string[];
7
- declare const filterAvailable: (filter: string) => boolean;
8
- declare const applyFilter: (predicate: string, ...fields: string[]) => string;
9
- declare const filters: () => Filter[];
10
- export { type Filter, documentation, filterAvailable as available, filterList as list, applyFilter as apply, filters };
package/lib/esm/filter.js DELETED
@@ -1 +0,0 @@
1
- import n from"./config";const l=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],c=n.doc.core_filtering_data,i=()=>o().map(t=>t.predicate.replace(/^\*/g,"")),r=t=>{const a=t.startsWith("_")?t:`_${t}`;return i().some(e=>a.endsWith(e))},d=(t,...a)=>{if(!r(t))throw new Error("Unknown filter: "+t);let e="";for(const s of a)e+=(e.length===0?"":"_or_")+s;return e+=t.startsWith("_")?t:`_${t}`,e},o=()=>[...l];export{c as documentation,r as available,i as list,d as apply,o as filters};