@optimizely-opal/opal-tool-ocp-sdk 0.0.0-beta.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 (42) hide show
  1. package/README.md +576 -0
  2. package/dist/decorator/Decorator.d.ts +46 -0
  3. package/dist/decorator/Decorator.d.ts.map +1 -0
  4. package/dist/decorator/Decorator.js +31 -0
  5. package/dist/decorator/Decorator.js.map +1 -0
  6. package/dist/decorator/Decorator.test.d.ts +2 -0
  7. package/dist/decorator/Decorator.test.d.ts.map +1 -0
  8. package/dist/decorator/Decorator.test.js +418 -0
  9. package/dist/decorator/Decorator.test.js.map +1 -0
  10. package/dist/function/ToolFunction.d.ts +15 -0
  11. package/dist/function/ToolFunction.d.ts.map +1 -0
  12. package/dist/function/ToolFunction.js +25 -0
  13. package/dist/function/ToolFunction.js.map +1 -0
  14. package/dist/function/ToolFunction.test.d.ts +2 -0
  15. package/dist/function/ToolFunction.test.d.ts.map +1 -0
  16. package/dist/function/ToolFunction.test.js +189 -0
  17. package/dist/function/ToolFunction.test.js.map +1 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +25 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/service/Service.d.ts +78 -0
  23. package/dist/service/Service.d.ts.map +1 -0
  24. package/dist/service/Service.js +204 -0
  25. package/dist/service/Service.js.map +1 -0
  26. package/dist/service/Service.test.d.ts +2 -0
  27. package/dist/service/Service.test.d.ts.map +1 -0
  28. package/dist/service/Service.test.js +341 -0
  29. package/dist/service/Service.test.js.map +1 -0
  30. package/dist/types/Models.d.ts +126 -0
  31. package/dist/types/Models.d.ts.map +1 -0
  32. package/dist/types/Models.js +181 -0
  33. package/dist/types/Models.js.map +1 -0
  34. package/package.json +58 -0
  35. package/src/decorator/Decorator.test.ts +523 -0
  36. package/src/decorator/Decorator.ts +83 -0
  37. package/src/function/ToolFunction.test.ts +224 -0
  38. package/src/function/ToolFunction.ts +25 -0
  39. package/src/index.ts +4 -0
  40. package/src/service/Service.test.ts +550 -0
  41. package/src/service/Service.ts +182 -0
  42. 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
+ customerId;
56
+ instanceId;
57
+ accessToken;
58
+ productSku;
59
+ constructor(customerId, instanceId, accessToken, productSku) {
60
+ this.customerId = customerId;
61
+ this.instanceId = instanceId;
62
+ this.accessToken = accessToken;
63
+ this.productSku = productSku;
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;CAC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ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@optimizely-opal/opal-tool-ocp-sdk",
3
+ "version": "0.0.0-beta.1",
4
+ "description": "OCP SDK for Opal tool",
5
+ "scripts": {
6
+ "build": "yarn tsc",
7
+ "build-watch": "tsc -w",
8
+ "lint": "npx eslint 'src/**/*.ts'",
9
+ "test": "jest",
10
+ "test:watch": "jest --watch",
11
+ "test:coverage": "jest --coverage"
12
+ },
13
+ "repository": "https://github.com/ZaiusInc/opal-tool-ocp-sdk",
14
+ "license": "Apache-2.0",
15
+ "author": "Optimizely, Inc",
16
+ "files": [
17
+ "dist/",
18
+ "src/"
19
+ ],
20
+ "main": "dist/index.js",
21
+ "module": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "directories": {
24
+ "test": "test"
25
+ },
26
+ "engines": {
27
+ "node": ">=22.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@eslint/compat": "^1.2.7",
31
+ "@stylistic/eslint-plugin": "^4.2.0",
32
+ "@types/jest": "^29.5.14",
33
+ "@types/node": "^22.13.10",
34
+ "@types/node-fetch": "^2.6.12",
35
+ "@typescript-eslint/eslint-plugin": "^8.27.0",
36
+ "@typescript-eslint/eslint-plugin-tslint": "^7.0.2",
37
+ "@typescript-eslint/parser": "^8.27.0",
38
+ "@zaiusinc/eslint-config-presets": "^2.0.0",
39
+ "copyfiles": "^2.4.1",
40
+ "cross-env": "^7.0.3",
41
+ "dotenv": "^16.5.0",
42
+ "eslint": "^9.22.0",
43
+ "eslint-plugin-import": "^2.31.0",
44
+ "eslint-plugin-jest": "^28.11.0",
45
+ "eslint-plugin-jsdoc": "^50.6.14",
46
+ "eslint-plugin-prefer-arrow": "^1.2.3",
47
+ "eslint-plugin-react": "^7.37.5",
48
+ "jest": "^29.7.0",
49
+ "rimraf": "^6.0.1",
50
+ "ts-jest": "^29.3.2",
51
+ "tslint": "^6.1.3",
52
+ "typescript": "^5.8.2"
53
+ },
54
+ "dependencies": {
55
+ "@zaiusinc/app-sdk": "2.2.2",
56
+ "reflect-metadata": "^0.2.2"
57
+ }
58
+ }