@optimizely-opal/opal-tool-ocp-sdk 0.0.0-OCP-1487.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +631 -0
  2. package/dist/auth/AuthUtils.d.ts +31 -0
  3. package/dist/auth/AuthUtils.d.ts.map +1 -0
  4. package/dist/auth/AuthUtils.js +64 -0
  5. package/dist/auth/AuthUtils.js.map +1 -0
  6. package/dist/auth/AuthUtils.test.d.ts +2 -0
  7. package/dist/auth/AuthUtils.test.d.ts.map +1 -0
  8. package/dist/auth/AuthUtils.test.js +469 -0
  9. package/dist/auth/AuthUtils.test.js.map +1 -0
  10. package/dist/auth/TokenVerifier.d.ts +31 -0
  11. package/dist/auth/TokenVerifier.d.ts.map +1 -0
  12. package/dist/auth/TokenVerifier.js +127 -0
  13. package/dist/auth/TokenVerifier.js.map +1 -0
  14. package/dist/auth/TokenVerifier.test.d.ts +2 -0
  15. package/dist/auth/TokenVerifier.test.d.ts.map +1 -0
  16. package/dist/auth/TokenVerifier.test.js +125 -0
  17. package/dist/auth/TokenVerifier.test.js.map +1 -0
  18. package/dist/decorator/Decorator.d.ts +48 -0
  19. package/dist/decorator/Decorator.d.ts.map +1 -0
  20. package/dist/decorator/Decorator.js +53 -0
  21. package/dist/decorator/Decorator.js.map +1 -0
  22. package/dist/decorator/Decorator.test.d.ts +2 -0
  23. package/dist/decorator/Decorator.test.d.ts.map +1 -0
  24. package/dist/decorator/Decorator.test.js +528 -0
  25. package/dist/decorator/Decorator.test.js.map +1 -0
  26. package/dist/function/GlobalToolFunction.d.ts +28 -0
  27. package/dist/function/GlobalToolFunction.d.ts.map +1 -0
  28. package/dist/function/GlobalToolFunction.js +56 -0
  29. package/dist/function/GlobalToolFunction.js.map +1 -0
  30. package/dist/function/GlobalToolFunction.test.d.ts +2 -0
  31. package/dist/function/GlobalToolFunction.test.d.ts.map +1 -0
  32. package/dist/function/GlobalToolFunction.test.js +425 -0
  33. package/dist/function/GlobalToolFunction.test.js.map +1 -0
  34. package/dist/function/ToolFunction.d.ts +28 -0
  35. package/dist/function/ToolFunction.d.ts.map +1 -0
  36. package/dist/function/ToolFunction.js +60 -0
  37. package/dist/function/ToolFunction.js.map +1 -0
  38. package/dist/function/ToolFunction.test.d.ts +2 -0
  39. package/dist/function/ToolFunction.test.d.ts.map +1 -0
  40. package/dist/function/ToolFunction.test.js +314 -0
  41. package/dist/function/ToolFunction.test.js.map +1 -0
  42. package/dist/index.d.ts +6 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +26 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/service/Service.d.ts +80 -0
  47. package/dist/service/Service.d.ts.map +1 -0
  48. package/dist/service/Service.js +210 -0
  49. package/dist/service/Service.js.map +1 -0
  50. package/dist/service/Service.test.d.ts +2 -0
  51. package/dist/service/Service.test.d.ts.map +1 -0
  52. package/dist/service/Service.test.js +427 -0
  53. package/dist/service/Service.test.js.map +1 -0
  54. package/dist/types/Models.d.ts +126 -0
  55. package/dist/types/Models.d.ts.map +1 -0
  56. package/dist/types/Models.js +181 -0
  57. package/dist/types/Models.js.map +1 -0
  58. package/package.json +64 -0
  59. package/src/auth/AuthUtils.test.ts +586 -0
  60. package/src/auth/AuthUtils.ts +66 -0
  61. package/src/auth/TokenVerifier.test.ts +165 -0
  62. package/src/auth/TokenVerifier.ts +145 -0
  63. package/src/decorator/Decorator.test.ts +649 -0
  64. package/src/decorator/Decorator.ts +111 -0
  65. package/src/function/GlobalToolFunction.test.ts +505 -0
  66. package/src/function/GlobalToolFunction.ts +61 -0
  67. package/src/function/ToolFunction.test.ts +374 -0
  68. package/src/function/ToolFunction.ts +64 -0
  69. package/src/index.ts +5 -0
  70. package/src/service/Service.test.ts +661 -0
  71. package/src/service/Service.ts +213 -0
  72. package/src/types/Models.ts +163 -0
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IslandResponse = exports.IslandConfig = exports.IslandAction = exports.IslandField = exports.AuthRequirement = exports.OptiIdAuthData = exports.OptiIdAuthDataCredentials = exports.Parameter = exports.ParameterType = void 0;
4
+ /* eslint-disable max-classes-per-file */
5
+ /**
6
+ * Types of parameters supported by Opal tools
7
+ */
8
+ var ParameterType;
9
+ (function (ParameterType) {
10
+ ParameterType["String"] = "string";
11
+ ParameterType["Integer"] = "integer";
12
+ ParameterType["Number"] = "number";
13
+ ParameterType["Boolean"] = "boolean";
14
+ ParameterType["List"] = "list";
15
+ ParameterType["Dictionary"] = "object";
16
+ })(ParameterType || (exports.ParameterType = ParameterType = {}));
17
+ /**
18
+ * Parameter definition for an Opal tool
19
+ */
20
+ class Parameter {
21
+ name;
22
+ type;
23
+ description;
24
+ required;
25
+ /**
26
+ * Create a new parameter definition
27
+ * @param name Parameter name
28
+ * @param type Parameter type
29
+ * @param description Parameter description
30
+ * @param required Whether the parameter is required
31
+ */
32
+ constructor(name, type, description, required) {
33
+ this.name = name;
34
+ this.type = type;
35
+ this.description = description;
36
+ this.required = required;
37
+ }
38
+ /**
39
+ * Convert to JSON for the discovery endpoint
40
+ */
41
+ toJSON() {
42
+ return {
43
+ name: this.name,
44
+ type: this.type,
45
+ description: this.description,
46
+ required: this.required
47
+ };
48
+ }
49
+ }
50
+ exports.Parameter = Parameter;
51
+ /**
52
+ * Credentials structure
53
+ */
54
+ class OptiIdAuthDataCredentials {
55
+ customer_id;
56
+ instance_id;
57
+ access_token;
58
+ product_sku;
59
+ constructor(customer_id, instance_id, access_token, product_sku) {
60
+ this.customer_id = customer_id;
61
+ this.instance_id = instance_id;
62
+ this.access_token = access_token;
63
+ this.product_sku = product_sku;
64
+ }
65
+ }
66
+ exports.OptiIdAuthDataCredentials = OptiIdAuthDataCredentials;
67
+ /**
68
+ * Auth data structure
69
+ */
70
+ class OptiIdAuthData {
71
+ provider;
72
+ credentials;
73
+ constructor(provider, credentials) {
74
+ this.provider = provider;
75
+ this.credentials = credentials;
76
+ }
77
+ }
78
+ exports.OptiIdAuthData = OptiIdAuthData;
79
+ /**
80
+ * Authentication requirements for an Opal tool
81
+ */
82
+ class AuthRequirement {
83
+ provider;
84
+ scopeBundle;
85
+ required;
86
+ /**
87
+ * Create a new authentication requirement
88
+ * @param provider Auth provider (e.g., "optiId")
89
+ * @param scopeBundle Scope bundle (e.g., "calendar", "drive")
90
+ * @param required Whether authentication is required
91
+ */
92
+ constructor(provider, scopeBundle, required = true) {
93
+ this.provider = provider;
94
+ this.scopeBundle = scopeBundle;
95
+ this.required = required;
96
+ }
97
+ /**
98
+ * Convert to JSON for the discovery endpoint
99
+ */
100
+ toJSON() {
101
+ return {
102
+ provider: this.provider,
103
+ scope_bundle: this.scopeBundle,
104
+ required: this.required
105
+ };
106
+ }
107
+ }
108
+ exports.AuthRequirement = AuthRequirement;
109
+ class IslandField {
110
+ name;
111
+ label;
112
+ type;
113
+ value;
114
+ hidden;
115
+ options;
116
+ constructor(name, label, type, value = '', hidden = false, options = []) {
117
+ this.name = name;
118
+ this.label = label;
119
+ this.type = type;
120
+ this.value = value;
121
+ this.hidden = hidden;
122
+ this.options = options;
123
+ }
124
+ toJSON() {
125
+ return {
126
+ name: this.name,
127
+ label: this.label,
128
+ type: this.type,
129
+ hidden: this.hidden,
130
+ options: this.options,
131
+ value: this.value
132
+ };
133
+ }
134
+ }
135
+ exports.IslandField = IslandField;
136
+ class IslandAction {
137
+ name;
138
+ label;
139
+ type;
140
+ endpoint;
141
+ operation;
142
+ constructor(name, label, type, endpoint, operation = 'create') {
143
+ this.name = name;
144
+ this.label = label;
145
+ this.type = type;
146
+ this.endpoint = endpoint;
147
+ this.operation = operation;
148
+ }
149
+ toJSON() {
150
+ return {
151
+ name: this.name,
152
+ label: this.label,
153
+ type: this.type,
154
+ endpoint: this.endpoint,
155
+ operation: this.operation
156
+ };
157
+ }
158
+ }
159
+ exports.IslandAction = IslandAction;
160
+ class IslandConfig {
161
+ fields;
162
+ actions;
163
+ constructor(fields, actions) {
164
+ this.fields = fields;
165
+ this.actions = actions;
166
+ }
167
+ }
168
+ exports.IslandConfig = IslandConfig;
169
+ class IslandResponse {
170
+ type;
171
+ config;
172
+ constructor(type, config) {
173
+ this.type = type;
174
+ this.config = config;
175
+ }
176
+ static create(islands) {
177
+ return new IslandResponse('island', { islands });
178
+ }
179
+ }
180
+ exports.IslandResponse = IslandResponse;
181
+ //# sourceMappingURL=Models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Models.js","sourceRoot":"","sources":["../../src/types/Models.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC;;GAEG;AACH,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,sCAAqB,CAAA;AACvB,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB;AAED;;GAEG;AACH,MAAa,SAAS;IASX;IACA;IACA;IACA;IAXT;;;;;;OAMG;IACH,YACS,IAAY,EACZ,IAAmB,EACnB,WAAmB,EACnB,QAAiB;QAHjB,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAe;QACnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAS;IACvB,CAAC;IAEJ;;OAEG;IACI,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF;AA1BD,8BA0BC;AAED;;GAEG;AACH,MAAa,yBAAyB;IAG3B;IACA;IACA;IACA;IAJT,YACS,WAAmB,EACnB,WAAmB,EACnB,YAAoB,EACpB,WAAmB;QAHnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,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AI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF;AArBD,kCAqBC;AAED,MAAa,YAAY;IAGd;IACA;IACA;IACA;IACA;IALT,YACS,IAAY,EACZ,KAAa,EACb,IAAY,EACZ,QAAgB,EAChB,YAAoB,QAAQ;QAJ5B,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAmB;IAClC,CAAC;IAEG,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF;AAnBD,oCAmBC;AAED,MAAa,YAAY;IAGd;IACA;IAFT,YACS,MAAqB,EACrB,OAAuB;QADvB,WAAM,GAAN,MAAM,CAAe;QACrB,YAAO,GAAP,OAAO,CAAgB;IAC7B,CAAC;CACL;AAND,oCAMC;AAED,MAAa,cAAc;IAGhB;IACA;IAFT,YACS,IAAc,EACd,MAEN;QAHM,SAAI,GAAJ,IAAI,CAAU;QACd,WAAM,GAAN,MAAM,CAEZ;IACA,CAAC;IAEG,MAAM,CAAC,MAAM,CAAC,OAAuB;QAC1C,OAAO,IAAI,cAAc,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAZD,wCAYC"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@optimizely-opal/opal-tool-ocp-sdk",
3
+ "version": "0.0.0-OCP-1487.1",
4
+ "description": "OCP SDK for Opal tool",
5
+ "scripts": {
6
+ "validate-deps": "node scripts/validate-deps.js",
7
+ "prebuild": "yarn run validate-deps",
8
+ "build": "yarn tsc",
9
+ "build-watch": "tsc -w",
10
+ "lint": "npx eslint 'src/**/*.ts'",
11
+ "test": "jest",
12
+ "test:watch": "jest --watch",
13
+ "test:coverage": "jest --coverage"
14
+ },
15
+ "repository": "https://github.com/ZaiusInc/opal-tool-ocp-sdk",
16
+ "license": "Apache-2.0",
17
+ "author": "Optimizely, Inc",
18
+ "files": [
19
+ "dist/",
20
+ "src/"
21
+ ],
22
+ "main": "dist/index.js",
23
+ "module": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "directories": {
26
+ "test": "test"
27
+ },
28
+ "engines": {
29
+ "node": ">=22.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@eslint/compat": "^1.2.7",
33
+ "@stylistic/eslint-plugin": "^4.2.0",
34
+ "@types/jest": "^29.5.14",
35
+ "@types/node": "^22.13.10",
36
+ "@types/node-fetch": "^2.6.12",
37
+ "@typescript-eslint/eslint-plugin": "^8.27.0",
38
+ "@typescript-eslint/eslint-plugin-tslint": "^7.0.2",
39
+ "@typescript-eslint/parser": "^8.27.0",
40
+ "@zaiusinc/eslint-config-presets": "^2.0.0",
41
+ "copyfiles": "^2.4.1",
42
+ "cross-env": "^7.0.3",
43
+ "dotenv": "^16.5.0",
44
+ "eslint": "^9.22.0",
45
+ "eslint-plugin-import": "^2.31.0",
46
+ "eslint-plugin-jest": "^28.11.0",
47
+ "eslint-plugin-jsdoc": "^50.6.14",
48
+ "eslint-plugin-prefer-arrow": "^1.2.3",
49
+ "eslint-plugin-react": "^7.37.5",
50
+ "jest": "^29.7.0",
51
+ "rimraf": "^6.0.1",
52
+ "ts-jest": "^29.3.2",
53
+ "tslint": "^6.1.3",
54
+ "typescript": "^5.8.2",
55
+ "@zaiusinc/app-sdk": "^2.2.4-devmg.2"
56
+ },
57
+ "dependencies": {
58
+ "jose": "^6.1.0",
59
+ "reflect-metadata": "^0.2.2"
60
+ },
61
+ "peerDependencies": {
62
+ "@zaiusinc/app-sdk": "^2.2.4-devmg.2"
63
+ }
64
+ }