@or-sdk/source 1.2.0-beta.1238.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.1.0 (2023-05-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * **source:** create package ([2506121](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/commit/250612105c81e16ce4703b706a62215e159abc08)), closes [#SA-22](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/issues/SA-22)
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @or-sdk/source
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ npm i @or-sdk/source
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ```typescript
12
+ import { Source } from '@or-sdk/source'
13
+ import config from '../config';
14
+
15
+ // With direct api url
16
+ const SourceSdk = new Source({
17
+ token: 'my-account-token-string',
18
+ storeApiUrl: config.STORE_API_URL
19
+ });
20
+
21
+ // With service discovery (slower)
22
+ const SourceSdk = new Store({
23
+ token: 'my-account-token-string',
24
+ discoveryUrl: 'http://example.store/endpoint'
25
+ });
26
+ ```
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __rest = (this && this.__rest) || function (s, e) {
54
+ var t = {};
55
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56
+ t[p] = s[p];
57
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
58
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60
+ t[p[i]] = s[p[i]];
61
+ }
62
+ return t;
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.Source = void 0;
66
+ var base_1 = require("@or-sdk/base");
67
+ var constants_1 = require("./constants");
68
+ var Source = (function (_super) {
69
+ __extends(Source, _super);
70
+ function Source(params) {
71
+ var _this = this;
72
+ var token = params.token, discoveryUrl = params.discoveryUrl, packageType = params.packageType, storeApiUrl = params.storeApiUrl;
73
+ _this = _super.call(this, {
74
+ discoveryUrl: discoveryUrl,
75
+ token: token,
76
+ serviceKey: constants_1.SERVICE_KEY,
77
+ serviceUrl: storeApiUrl,
78
+ useDefaultSerializer: false,
79
+ }) || this;
80
+ _this.packageType = packageType;
81
+ return _this;
82
+ }
83
+ Source.prototype.addProject = function (data, _a) {
84
+ var _b = _a === void 0 ? {} : _a, type = _b.type, signal = _b.signal;
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var packageType;
87
+ return __generator(this, function (_c) {
88
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
89
+ return [2, this.callApi({
90
+ method: 'POST',
91
+ route: "/api/v1/sources/".concat(packageType),
92
+ signal: signal,
93
+ data: data,
94
+ })];
95
+ });
96
+ });
97
+ };
98
+ Source.prototype.getProjects = function (pagination, _a) {
99
+ var _b = _a === void 0 ? {} : _a, type = _b.type, signal = _b.signal;
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ var packageType;
102
+ return __generator(this, function (_c) {
103
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
104
+ return [2, this.callApi({
105
+ method: 'GET',
106
+ route: "/api/v1/sources/".concat(packageType),
107
+ signal: signal,
108
+ })];
109
+ });
110
+ });
111
+ };
112
+ Source.prototype.getProject = function (_a, _b) {
113
+ var id = _a.id;
114
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ var packageType;
117
+ return __generator(this, function (_d) {
118
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
119
+ return [2, this.callApi({
120
+ method: 'GET',
121
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id),
122
+ signal: signal,
123
+ })];
124
+ });
125
+ });
126
+ };
127
+ Source.prototype.patchProjectMeta = function (_a, _b) {
128
+ var id = _a.id, data = __rest(_a, ["id"]);
129
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ var packageType;
132
+ return __generator(this, function (_d) {
133
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
134
+ return [2, this.callApi({
135
+ method: 'PATCH',
136
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/meta"),
137
+ data: data,
138
+ signal: signal,
139
+ })];
140
+ });
141
+ });
142
+ };
143
+ Source.prototype.deleteProject = function (_a, _b) {
144
+ var id = _a.id;
145
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
146
+ return __awaiter(this, void 0, void 0, function () {
147
+ var packageType;
148
+ return __generator(this, function (_d) {
149
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
150
+ return [2, this.callApi({
151
+ method: 'DELETE',
152
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id),
153
+ signal: signal,
154
+ })];
155
+ });
156
+ });
157
+ };
158
+ Source.prototype.getBranch = function (_a, _b) {
159
+ var id = _a.id, sourceId = _a.sourceId;
160
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
161
+ return __awaiter(this, void 0, void 0, function () {
162
+ var packageType;
163
+ return __generator(this, function (_d) {
164
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
165
+ return [2, this.callApi({
166
+ method: 'GET',
167
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId),
168
+ signal: signal,
169
+ })];
170
+ });
171
+ });
172
+ };
173
+ Source.prototype.deleteBranch = function (_a, _b) {
174
+ var id = _a.id, sourceId = _a.sourceId;
175
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var packageType;
178
+ return __generator(this, function (_d) {
179
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
180
+ return [2, this.callApi({
181
+ method: 'DELETE',
182
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId),
183
+ signal: signal,
184
+ })];
185
+ });
186
+ });
187
+ };
188
+ Source.prototype.patchBranchMeta = function (_a, _b) {
189
+ var id = _a.id, sourceId = _a.sourceId, data = __rest(_a, ["id", "sourceId"]);
190
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
191
+ return __awaiter(this, void 0, void 0, function () {
192
+ var packageType;
193
+ return __generator(this, function (_d) {
194
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
195
+ return [2, this.callApi({
196
+ method: 'PATCH',
197
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId, "/meta"),
198
+ data: data,
199
+ signal: signal,
200
+ })];
201
+ });
202
+ });
203
+ };
204
+ Source.prototype.forkBranch = function (_a, _b) {
205
+ var id = _a.id, sourceId = _a.sourceId, data = __rest(_a, ["id", "sourceId"]);
206
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
207
+ return __awaiter(this, void 0, void 0, function () {
208
+ var packageType;
209
+ return __generator(this, function (_d) {
210
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
211
+ return [2, this.callApi({
212
+ method: 'POST',
213
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId, "/fork"),
214
+ data: data,
215
+ signal: signal,
216
+ })];
217
+ });
218
+ });
219
+ };
220
+ Source.prototype.setPublished = function (_a, _b) {
221
+ var id = _a.id, sourceId = _a.sourceId, data = __rest(_a, ["id", "sourceId"]);
222
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
223
+ return __awaiter(this, void 0, void 0, function () {
224
+ var packageType;
225
+ return __generator(this, function (_d) {
226
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
227
+ return [2, this.callApi({
228
+ method: 'POST',
229
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId, "/published"),
230
+ data: data,
231
+ signal: signal,
232
+ })];
233
+ });
234
+ });
235
+ };
236
+ Source.prototype.getRevision = function (_a, _b) {
237
+ var id = _a.id, sourceId = _a.sourceId, revisionId = _a.revisionId;
238
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
239
+ return __awaiter(this, void 0, void 0, function () {
240
+ var packageType;
241
+ return __generator(this, function (_d) {
242
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
243
+ return [2, this.callApi({
244
+ method: 'GET',
245
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId, "/revision/").concat(revisionId),
246
+ signal: signal,
247
+ })];
248
+ });
249
+ });
250
+ };
251
+ Source.prototype.addRevision = function (_a, _b) {
252
+ var id = _a.id, sourceId = _a.sourceId, data = __rest(_a, ["id", "sourceId"]);
253
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
254
+ return __awaiter(this, void 0, void 0, function () {
255
+ var packageType;
256
+ return __generator(this, function (_d) {
257
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
258
+ return [2, this.callApi({
259
+ method: 'POST',
260
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId, "/revision"),
261
+ data: data,
262
+ signal: signal,
263
+ })];
264
+ });
265
+ });
266
+ };
267
+ Source.prototype.setSandbox = function (_a, _b) {
268
+ var id = _a.id, sourceId = _a.sourceId, revisionId = _a.revisionId, data = __rest(_a, ["id", "sourceId", "revisionId"]);
269
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
270
+ return __awaiter(this, void 0, void 0, function () {
271
+ var packageType;
272
+ return __generator(this, function (_d) {
273
+ packageType = type !== null && type !== void 0 ? type : this.packageType;
274
+ return [2, this.callApi({
275
+ method: 'POST',
276
+ route: "/api/v1/sources/".concat(packageType, "/").concat(id, "/source/").concat(sourceId, "/revision/").concat(revisionId, "/sandbox"),
277
+ data: data,
278
+ signal: signal,
279
+ })];
280
+ });
281
+ });
282
+ };
283
+ return Source;
284
+ }(base_1.Base));
285
+ exports.Source = Source;
286
+ //# sourceMappingURL=Source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Source.js","sourceRoot":"","sources":["../../src/Source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoC;AACpC,yCAA0C;AAgB1C;IAA4B,0BAAI;IAc9B,gBAAY,MAAoB;QAAhC,iBAYC;QAXS,IAAA,KAAK,GAA6C,MAAM,MAAnD,EAAE,YAAY,GAA+B,MAAM,aAArC,EAAE,WAAW,GAAkB,MAAM,YAAxB,EAAE,WAAW,GAAK,MAAM,YAAX,CAAY;gBAEjE,kBAAM;YACJ,YAAY,cAAA;YACZ,KAAK,OAAA;YACL,UAAU,EAAE,uBAAW;YACvB,UAAU,EAAE,WAAW;YACvB,oBAAoB,EAAE,KAAK;SAC5B,CAAC;QAEF,KAAI,CAAC,WAAW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AK,EAAE,0BAAmB,WAAW,cAAI,EAAE,qBAAW,QAAQ,cAAW;wBACzE,IAAI,MAAA;wBACJ,MAAM,QAAA;qBACP,CAAC,EAAC;;;KACJ;IAQK,2BAAU,GAAhB,UACE,EAAuE,EACvE,EAAqC;QADnC,IAAA,EAAE,QAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAA,EAAK,IAAI,cAAnC,gCAAqC,CAAF;YACnC,qBAAmC,EAAE,KAAA,EAAnC,IAAI,UAAA,EAAE,MAAM,YAAA;;;;gBAER,WAAW,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC,WAAW,CAAC;gBAE7C,WAAO,IAAI,CAAC,OAAO,CAAC;wBAClB,MAAM,EAAE,MAAM;wBACd,KAAK,EAAE,0BAAmB,WAAW,cAAI,EAAE,qBAAW,QAAQ,uBAAa,UAAU,aAAU;wBAC/F,IAAI,MAAA;wBACJ,MAAM,QAAA;qBACP,CAAC,EAAC;;;KACJ;IACH,aAAC;AAAD,CAAC,AAtQD,CAA4B,WAAI,GAsQ/B;AAtQY,wBAAM"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PACKAGE_TYPE = exports.STORE_API_URL_KEY = exports.STORE_SERVICE_KEY = exports.SERVICE_KEY = void 0;
4
+ exports.SERVICE_KEY = 'store-api';
5
+ exports.STORE_SERVICE_KEY = exports.SERVICE_KEY;
6
+ exports.STORE_API_URL_KEY = 'STORE_API_URL';
7
+ exports.PACKAGE_TYPE = {
8
+ STEP: 'STEP',
9
+ STEP_INPUT: 'STEP_INPUT',
10
+ TICKET_INPUT: 'TICKET_INPUT',
11
+ CONTENT_INPUT: 'CONTENT_INPUT',
12
+ };
13
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,WAAW,CAAC;AAC1B,QAAA,iBAAiB,GAAG,mBAAW,CAAC;AAChC,QAAA,iBAAiB,GAAG,eAAe,CAAC;AAEpC,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;CACtB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Source = void 0;
18
+ var Source_1 = require("./Source");
19
+ Object.defineProperty(exports, "Source", { enumerable: true, get: function () { return Source_1.Source; } });
20
+ __exportStar(require("./types"), exports);
21
+ __exportStar(require("./constants"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,0CAAwB;AACxB,8CAA4B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,185 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import { Base } from '@or-sdk/base';
22
+ import { SERVICE_KEY } from './constants';
23
+ export class Source extends Base {
24
+ constructor(params) {
25
+ const { token, discoveryUrl, packageType, storeApiUrl } = params;
26
+ super({
27
+ discoveryUrl,
28
+ token,
29
+ serviceKey: SERVICE_KEY,
30
+ serviceUrl: storeApiUrl,
31
+ useDefaultSerializer: false,
32
+ });
33
+ this.packageType = packageType;
34
+ }
35
+ addProject(data, { type, signal } = {}) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
38
+ return this.callApi({
39
+ method: 'POST',
40
+ route: `/api/v1/sources/${packageType}`,
41
+ signal,
42
+ data,
43
+ });
44
+ });
45
+ }
46
+ getProjects(pagination, { type, signal } = {}) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
49
+ return this.callApi({
50
+ method: 'GET',
51
+ route: `/api/v1/sources/${packageType}`,
52
+ signal,
53
+ });
54
+ });
55
+ }
56
+ getProject({ id }, { type, signal } = {}) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
59
+ return this.callApi({
60
+ method: 'GET',
61
+ route: `/api/v1/sources/${packageType}/${id}`,
62
+ signal,
63
+ });
64
+ });
65
+ }
66
+ patchProjectMeta(_a, _b) {
67
+ var { id } = _a, data = __rest(_a, ["id"]);
68
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
71
+ return this.callApi({
72
+ method: 'PATCH',
73
+ route: `/api/v1/sources/${packageType}/${id}/meta`,
74
+ data,
75
+ signal,
76
+ });
77
+ });
78
+ }
79
+ deleteProject({ id }, { type, signal } = {}) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
82
+ return this.callApi({
83
+ method: 'DELETE',
84
+ route: `/api/v1/sources/${packageType}/${id}`,
85
+ signal,
86
+ });
87
+ });
88
+ }
89
+ getBranch({ id, sourceId }, { type, signal } = {}) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
92
+ return this.callApi({
93
+ method: 'GET',
94
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}`,
95
+ signal,
96
+ });
97
+ });
98
+ }
99
+ deleteBranch({ id, sourceId }, { type, signal } = {}) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
102
+ return this.callApi({
103
+ method: 'DELETE',
104
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}`,
105
+ signal,
106
+ });
107
+ });
108
+ }
109
+ patchBranchMeta(_a, _b) {
110
+ var { id, sourceId } = _a, data = __rest(_a, ["id", "sourceId"]);
111
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
114
+ return this.callApi({
115
+ method: 'PATCH',
116
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/meta`,
117
+ data,
118
+ signal,
119
+ });
120
+ });
121
+ }
122
+ forkBranch(_a, _b) {
123
+ var { id, sourceId } = _a, data = __rest(_a, ["id", "sourceId"]);
124
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
127
+ return this.callApi({
128
+ method: 'POST',
129
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/fork`,
130
+ data,
131
+ signal,
132
+ });
133
+ });
134
+ }
135
+ setPublished(_a, _b) {
136
+ var { id, sourceId } = _a, data = __rest(_a, ["id", "sourceId"]);
137
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
140
+ return this.callApi({
141
+ method: 'POST',
142
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/published`,
143
+ data,
144
+ signal,
145
+ });
146
+ });
147
+ }
148
+ getRevision({ id, sourceId, revisionId }, { type, signal } = {}) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
151
+ return this.callApi({
152
+ method: 'GET',
153
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/revision/${revisionId}`,
154
+ signal,
155
+ });
156
+ });
157
+ }
158
+ addRevision(_a, _b) {
159
+ var { id, sourceId } = _a, data = __rest(_a, ["id", "sourceId"]);
160
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
163
+ return this.callApi({
164
+ method: 'POST',
165
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/revision`,
166
+ data,
167
+ signal,
168
+ });
169
+ });
170
+ }
171
+ setSandbox(_a, _b) {
172
+ var { id, sourceId, revisionId } = _a, data = __rest(_a, ["id", "sourceId", "revisionId"]);
173
+ var _c = _b === void 0 ? {} : _b, type = _c.type, signal = _c.signal;
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ const packageType = type !== null && type !== void 0 ? type : this.packageType;
176
+ return this.callApi({
177
+ method: 'POST',
178
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/revision/${revisionId}/sandbox`,
179
+ data,
180
+ signal,
181
+ });
182
+ });
183
+ }
184
+ }
185
+ //# sourceMappingURL=Source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Source.js","sourceRoot":"","sources":["../../src/Source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB1C,MAAM,OAAO,MAAO,SAAQ,IAAI;IAc9B,YAAY,MAAoB;QAC9B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QAEjE,KAAK,CAAC;YACJ,YAAY;YACZ,KAAK;YACL,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,WAAW;YACvB,oBAAoB,EAAE,KAAK;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAQK,UAAU,CAAC,IAAsB,EAAE,EAAE,IAAI,EAAE,MAAM,KAAqB,EAAE;;YAC5E,MAAM,WAAW,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC,WAAW,CAAC;YAC7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E_KEY;
3
+ export const STORE_API_URL_KEY = 'STORE_API_URL';
4
+ export const PACKAGE_TYPE = {
5
+ STEP: 'STEP',
6
+ STEP_INPUT: 'STEP_INPUT',
7
+ TICKET_INPUT: 'TICKET_INPUT',
8
+ CONTENT_INPUT: 'CONTENT_INPUT',
9
+ };
10
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;CACtB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Source } from './Source';
2
+ export * from './types';
3
+ export * from './constants';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { Base } from '@or-sdk/base';
2
+ import { SourceConfig, OptionalParams, CreateBranchData, GetParams, UniversalGetParams, PatchPackageMetaData, MetaObjectData, VersionData, AddRevisionData, PaginationParams } from './types';
3
+ export declare class Source extends Base {
4
+ private readonly packageType;
5
+ constructor(params: SourceConfig);
6
+ addProject(data: CreateBranchData, { type, signal }?: OptionalParams): Promise<unknown>;
7
+ getProjects(pagination: PaginationParams, { type, signal }?: OptionalParams): Promise<unknown>;
8
+ getProject({ id }: Pick<GetParams, 'id'>, { type, signal }?: OptionalParams): Promise<unknown>;
9
+ patchProjectMeta({ id, ...data }: Pick<GetParams, 'id'> & PatchPackageMetaData, { type, signal }?: OptionalParams): Promise<unknown>;
10
+ deleteProject({ id }: Pick<GetParams, 'id'>, { type, signal }?: OptionalParams): Promise<unknown>;
11
+ getBranch({ id, sourceId }: GetParams, { type, signal }?: OptionalParams): Promise<unknown>;
12
+ deleteBranch({ id, sourceId }: GetParams, { type, signal }?: OptionalParams): Promise<unknown>;
13
+ patchBranchMeta({ id, sourceId, ...data }: GetParams & MetaObjectData, { type, signal }?: OptionalParams): Promise<unknown>;
14
+ forkBranch({ id, sourceId, ...data }: GetParams & MetaObjectData, { type, signal }?: OptionalParams): Promise<unknown>;
15
+ setPublished({ id, sourceId, ...data }: GetParams & VersionData, { type, signal }?: OptionalParams): Promise<unknown>;
16
+ getRevision({ id, sourceId, revisionId }: UniversalGetParams, { type, signal }?: OptionalParams): Promise<unknown>;
17
+ addRevision({ id, sourceId, ...data }: GetParams & AddRevisionData, { type, signal }?: OptionalParams): Promise<unknown>;
18
+ setSandbox({ id, sourceId, revisionId, ...data }: UniversalGetParams & VersionData, { type, signal }?: OptionalParams): Promise<unknown>;
19
+ }
20
+ //# sourceMappingURL=Source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Source.d.ts","sourceRoot":"","sources":["../../src/Source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EACL,YAAY,EACZ,cAAc,EAEd,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAGjB,qBAAa,MAAO,SAAQ,IAAI;IAC9B,OA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AAG,IAAI,EAAE,EAAE,SAAS,GAAG,WAAW,EAClD,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB;IAkBjC,WAAW,CACf,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,kBAAkB,EAChD,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB;IAiBjC,WAAW,CACf,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,GAAG,eAAe,EACtD,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB;IAkBjC,UAAU,CACd,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,kBAAkB,GAAG,WAAW,EACvE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB;CAWxC"}
@@ -0,0 +1,10 @@
1
+ export declare const SERVICE_KEY = "store-api";
2
+ export declare const STORE_SERVICE_KEY = "store-api";
3
+ export declare const STORE_API_URL_KEY = "STORE_API_URL";
4
+ export declare const PACKAGE_TYPE: {
5
+ readonly STEP: "STEP";
6
+ readonly STEP_INPUT: "STEP_INPUT";
7
+ readonly TICKET_INPUT: "TICKET_INPUT";
8
+ readonly CONTENT_INPUT: "CONTENT_INPUT";
9
+ };
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,eAAO,MAAM,YAAY;;;;;CAKf,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Source } from './Source';
2
+ export * from './types';
3
+ export * from './constants';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { Token } from '@or-sdk/base';
2
+ import { PACKAGE_TYPE } from './constants';
3
+ export type PackageType = ObjectValues<typeof PACKAGE_TYPE>;
4
+ export type SourceConfig = {
5
+ token: Token;
6
+ discoveryUrl?: string;
7
+ storeUrl?: string;
8
+ storeApiUrl?: string;
9
+ packageType: PackageType;
10
+ };
11
+ export type ObjectValues<T> = T[keyof T];
12
+ export type JSONObject = {
13
+ [key: string]: JSONValue;
14
+ };
15
+ export type JSONArray = JSONValue[];
16
+ export type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
17
+ export type GetParams = {
18
+ id: string;
19
+ sourceId: string;
20
+ };
21
+ export type UniversalGetParams = GetParams & {
22
+ revisionId?: string;
23
+ };
24
+ export type OptionalParams = {
25
+ type?: string;
26
+ signal?: AbortSignal;
27
+ };
28
+ export type CreateBranchData = {
29
+ id?: string;
30
+ meta: {
31
+ label: string;
32
+ mocks?: JSONObject;
33
+ };
34
+ source: {
35
+ data?: {
36
+ helpTextSource?: string;
37
+ hooksSource?: string;
38
+ migrationSource?: string;
39
+ logicSource?: string;
40
+ } | JSONObject;
41
+ meta?: JSONObject;
42
+ packageMeta: {
43
+ categories?: string[];
44
+ description?: string;
45
+ icon?: string;
46
+ iconType?: string;
47
+ id?: string;
48
+ label?: string;
49
+ recommendedSteps?: string[];
50
+ shape?: string;
51
+ tags?: string[];
52
+ version?: string;
53
+ } | JSONObject;
54
+ };
55
+ };
56
+ export type PatchPackageMetaData = {
57
+ meta: {
58
+ label: string;
59
+ };
60
+ } | {
61
+ meta: {
62
+ shared: {
63
+ currentAccount: boolean;
64
+ };
65
+ };
66
+ };
67
+ export type MetaObjectData = {
68
+ meta: JSONObject;
69
+ };
70
+ export type VersionData = {
71
+ version: string;
72
+ };
73
+ export type AddRevisionData = {
74
+ data: JSONObject;
75
+ meta?: JSONObject;
76
+ packageMeta?: JSONObject;
77
+ };
78
+ export type CursorV1 = {
79
+ from: number;
80
+ };
81
+ export type PaginationParams = {
82
+ cursor?: CursorV1;
83
+ size?: number;
84
+ };
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG;IAIzB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,WAAW,CAAC,EAAE,MAAM,CAAC;IAKrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACzC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAAE,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AACpC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;AAElF,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE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MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@or-sdk/source",
3
+ "version": "1.2.0-beta.1238.0",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
9
+ "build:cjs": "tsc --project tsconfig.json",
10
+ "build:esm": "tsc --project tsconfig.esm.json",
11
+ "build:types": "tsc --project tsconfig.types.json",
12
+ "build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
13
+ "build:watch:cjs": "tsc --project tsconfig.json -w",
14
+ "build:watch:esm": "tsc --project tsconfig.esm.json -w",
15
+ "build:watch:types": "tsc --project tsconfig.types.json -w",
16
+ "clean": "rm -rf ./dist",
17
+ "dev": "pnpm build:watch:esm"
18
+ },
19
+ "dependencies": {
20
+ "@or-sdk/base": "^0.28.1"
21
+ },
22
+ "devDependencies": {
23
+ "concurrently": "^6.4.0",
24
+ "typescript": "^4.4.4"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }
package/src/Source.ts ADDED
@@ -0,0 +1,280 @@
1
+ import { Base } from '@or-sdk/base';
2
+ import { SERVICE_KEY } from './constants';
3
+ import {
4
+ SourceConfig,
5
+ OptionalParams,
6
+ PackageType,
7
+ CreateBranchData,
8
+ GetParams,
9
+ UniversalGetParams,
10
+ PatchPackageMetaData,
11
+ MetaObjectData,
12
+ VersionData,
13
+ AddRevisionData,
14
+ PaginationParams,
15
+ } from './types';
16
+
17
+
18
+ export class Source extends Base {
19
+ private readonly packageType: PackageType;
20
+
21
+ /**
22
+ * ```typescript
23
+ * import { Source } from '@or-sdk/source';
24
+ * import config from '../config';
25
+ *
26
+ * const source = new Source({
27
+ * token: 'my-account-token-string',
28
+ * storeApiUrl: config.STORE_API_URL
29
+ * });
30
+ * ```
31
+ */
32
+ constructor(params: SourceConfig) {
33
+ const { token, discoveryUrl, packageType, storeApiUrl } = params;
34
+
35
+ super({
36
+ discoveryUrl,
37
+ token,
38
+ serviceKey: SERVICE_KEY,
39
+ serviceUrl: storeApiUrl,
40
+ useDefaultSerializer: false,
41
+ });
42
+
43
+ this.packageType = packageType;
44
+ }
45
+
46
+ /**
47
+ * Add Project
48
+ * ```typescript
49
+ * const result = await source.addProject(data, { type });
50
+ * ```
51
+ */
52
+ async addProject(data: CreateBranchData, { type, signal }: OptionalParams = {}) {
53
+ const packageType = type ?? this.packageType;
54
+ return this.callApi({
55
+ method: 'POST',
56
+ route: `/api/v1/sources/${packageType}`,
57
+ signal,
58
+ data,
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Get Projects
64
+ * ```typescript
65
+ * const result = await source.addProjects({ type });
66
+ * ```
67
+ */
68
+ async getProjects(pagination: PaginationParams, { type, signal }: OptionalParams = {}) {
69
+ const packageType = type ?? this.packageType;
70
+
71
+ return this.callApi({
72
+ method: 'GET',
73
+ route: `/api/v1/sources/${packageType}`,
74
+ signal,
75
+ });
76
+ }
77
+
78
+ /**
79
+ * Get Project
80
+ * ```typescript
81
+ * const result = await source.getProject({ id },{ type });
82
+ * ```
83
+ */
84
+ async getProject({ id }: Pick<GetParams, 'id'>, { type, signal }: OptionalParams = {}) {
85
+ const packageType = type ?? this.packageType;
86
+
87
+ return this.callApi({
88
+ method: 'GET',
89
+ route: `/api/v1/sources/${packageType}/${id}`,
90
+ signal,
91
+ });
92
+ }
93
+
94
+ /**
95
+ * Patch Project Meta
96
+ * ```typescript
97
+ * const result = await source.patchProjectMeta(data, { type });
98
+ * ```
99
+ */
100
+ async patchProjectMeta(
101
+ { id, ...data }: Pick<GetParams, 'id'> & PatchPackageMetaData,
102
+ { type, signal }: OptionalParams = {}
103
+ ) {
104
+ const packageType = type ?? this.packageType;
105
+
106
+ return this.callApi({
107
+ method: 'PATCH',
108
+ route: `/api/v1/sources/${packageType}/${id}/meta`,
109
+ data,
110
+ signal,
111
+ });
112
+ }
113
+
114
+ /**
115
+ * Delete Project
116
+ * ```typescript
117
+ * const result = await source.deleteProject({ id },{ type });
118
+ * ```
119
+ */
120
+ async deleteProject({ id }: Pick<GetParams, 'id'>, { type, signal }: OptionalParams = {}) {
121
+ const packageType = type ?? this.packageType;
122
+
123
+ return this.callApi({
124
+ method: 'DELETE',
125
+ route: `/api/v1/sources/${packageType}/${id}`,
126
+ signal,
127
+ });
128
+ }
129
+
130
+ /**
131
+ * Get Branches
132
+ * ```typescript
133
+ * const result = await source.getBranch({ id, sourceId },{ type });
134
+ * ```
135
+ */
136
+ async getBranch({ id, sourceId }: GetParams, { type, signal }: OptionalParams = {}) {
137
+ const packageType = type ?? this.packageType;
138
+
139
+ return this.callApi({
140
+ method: 'GET',
141
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}`,
142
+ signal,
143
+ });
144
+ }
145
+
146
+ /**
147
+ * Delete Branch
148
+ * ```typescript
149
+ * const result = await source.deleteBranch({ id, sourceId },{ type });
150
+ * ```
151
+ */
152
+ async deleteBranch({ id, sourceId }: GetParams, { type, signal }: OptionalParams = {}) {
153
+ const packageType = type ?? this.packageType;
154
+
155
+ return this.callApi({
156
+ method: 'DELETE',
157
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}`,
158
+ signal,
159
+ });
160
+ }
161
+
162
+ /**
163
+ * Patch Branch Meta
164
+ * ```typescript
165
+ * const result = await source.patchBranchMeta({ id, sourceId, ...data },{ type });
166
+ * ```
167
+ */
168
+ async patchBranchMeta(
169
+ { id, sourceId, ...data }: GetParams & MetaObjectData,
170
+ { type, signal }: OptionalParams = {}
171
+ ) {
172
+ const packageType = type ?? this.packageType;
173
+
174
+ return this.callApi({
175
+ method: 'PATCH',
176
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/meta`,
177
+ data,
178
+ signal,
179
+ });
180
+ }
181
+
182
+ /**
183
+ * Fork Branch
184
+ * ```typescript
185
+ * const result = await source.forkBranch({ id, sourceId, ...data },{ type });
186
+ * ```
187
+ */
188
+ async forkBranch(
189
+ { id, sourceId, ...data }: GetParams & MetaObjectData,
190
+ { type, signal }: OptionalParams = {}
191
+ ) {
192
+ const packageType = type ?? this.packageType;
193
+
194
+ return this.callApi({
195
+ method: 'POST',
196
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/fork`,
197
+ data,
198
+ signal,
199
+ });
200
+ }
201
+
202
+ /**
203
+ * Set Published
204
+ * ```typescript
205
+ * const result = await source.setPublished({ id, sourceId, version },{ type });
206
+ * ```
207
+ */
208
+ async setPublished(
209
+ { id, sourceId, ...data }: GetParams & VersionData,
210
+ { type, signal }: OptionalParams = {}
211
+ ) {
212
+ const packageType = type ?? this.packageType;
213
+
214
+ return this.callApi({
215
+ method: 'POST',
216
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/published`,
217
+ data,
218
+ signal,
219
+ });
220
+ }
221
+
222
+ /**
223
+ * Get Revision
224
+ * ```typescript
225
+ * const result = await source.getRevision({ id, sourceId, revisionId },{ type });
226
+ * ```
227
+ */
228
+ async getRevision(
229
+ { id, sourceId, revisionId }: UniversalGetParams,
230
+ { type, signal }: OptionalParams = {}
231
+ ) {
232
+ const packageType = type ?? this.packageType;
233
+
234
+ return this.callApi({
235
+ method: 'GET',
236
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/revision/${revisionId}`,
237
+ signal,
238
+ });
239
+ }
240
+
241
+ /**
242
+ * Add Revision
243
+ * ```typescript
244
+ * const result = await source.addRevision({ id, sourceId, ...data },{ type });
245
+ * ```
246
+ */
247
+ async addRevision(
248
+ { id, sourceId, ...data }: GetParams & AddRevisionData,
249
+ { type, signal }: OptionalParams = {}
250
+ ) {
251
+ const packageType = type ?? this.packageType;
252
+
253
+ return this.callApi({
254
+ method: 'POST',
255
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/revision`,
256
+ data,
257
+ signal,
258
+ });
259
+ }
260
+
261
+ /**
262
+ * Set Sandbox
263
+ * ```typescript
264
+ * const result = await source.setSandbox({ id, sourceId, revisionId, ...data },{ type });
265
+ * ```
266
+ */
267
+ async setSandbox(
268
+ { id, sourceId, revisionId, ...data }: UniversalGetParams & VersionData,
269
+ { type, signal }: OptionalParams = {}
270
+ ) {
271
+ const packageType = type ?? this.packageType;
272
+
273
+ return this.callApi({
274
+ method: 'POST',
275
+ route: `/api/v1/sources/${packageType}/${id}/source/${sourceId}/revision/${revisionId}/sandbox`,
276
+ data,
277
+ signal,
278
+ });
279
+ }
280
+ }
@@ -0,0 +1,10 @@
1
+ export const SERVICE_KEY = 'store-api';
2
+ export const STORE_SERVICE_KEY = SERVICE_KEY;
3
+ export const STORE_API_URL_KEY = 'STORE_API_URL';
4
+
5
+ export const PACKAGE_TYPE = {
6
+ STEP: 'STEP',
7
+ STEP_INPUT: 'STEP_INPUT',
8
+ TICKET_INPUT: 'TICKET_INPUT',
9
+ CONTENT_INPUT: 'CONTENT_INPUT',
10
+ } as const;
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { Source } from './Source';
2
+ export * from './types';
3
+ export * from './constants';
package/src/types.ts ADDED
@@ -0,0 +1,114 @@
1
+ import { Token } from '@or-sdk/base';
2
+ import { PACKAGE_TYPE } from './constants';
3
+
4
+ export type PackageType = ObjectValues<typeof PACKAGE_TYPE>;
5
+
6
+ export type SourceConfig = {
7
+ /**
8
+ * token
9
+ */
10
+ token: Token;
11
+
12
+ /**
13
+ * Url of OneReach service discovery api
14
+ */
15
+ discoveryUrl?: string;
16
+
17
+ /**
18
+ * @deprecated Use storeApiUrl instead
19
+ */
20
+ storeUrl?: string;
21
+
22
+ /**
23
+ * Url of OneReach Store api
24
+ */
25
+ storeApiUrl?: string;
26
+
27
+ /**
28
+ * Package type
29
+ */
30
+ packageType: PackageType;
31
+ };
32
+
33
+ export type ObjectValues<T> = T[keyof T];
34
+ export type JSONObject = { [key: string]: JSONValue; };
35
+ export type JSONArray = JSONValue[];
36
+ export type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
37
+
38
+ export type GetParams = {
39
+ id: string;
40
+ sourceId: string;
41
+ };
42
+
43
+ export type UniversalGetParams = GetParams & {
44
+ revisionId?: string;
45
+ };
46
+
47
+ export type OptionalParams = {
48
+ type?: string;
49
+ signal?: AbortSignal;
50
+ };
51
+
52
+ export type CreateBranchData = {
53
+ id?: string;
54
+ meta: {
55
+ label: string;
56
+ mocks?: JSONObject;
57
+ };
58
+ source: {
59
+ data?: {
60
+ helpTextSource?: string;
61
+ hooksSource?: string;
62
+ migrationSource?: string;
63
+ logicSource?: string;
64
+ } | JSONObject;
65
+ meta?: JSONObject;
66
+ packageMeta: {
67
+ categories?: string[];
68
+ description?: string;
69
+ icon?: string;
70
+ iconType?: string;
71
+ id?: string;
72
+ label?: string;
73
+ recommendedSteps?: string[];
74
+ shape?: string;
75
+ tags?: string[];
76
+ version?: string;
77
+ } | JSONObject;
78
+ };
79
+ };
80
+
81
+ export type PatchPackageMetaData = {
82
+ meta: {
83
+ label: string;
84
+ };
85
+ } | {
86
+ meta: {
87
+ shared: {
88
+ currentAccount: boolean;
89
+ };
90
+ };
91
+ };
92
+
93
+ export type MetaObjectData = {
94
+ meta: JSONObject;
95
+ };
96
+
97
+ export type VersionData = {
98
+ version: string;
99
+ };
100
+
101
+ export type AddRevisionData = {
102
+ data: JSONObject;
103
+ meta?: JSONObject;
104
+ packageMeta?: JSONObject;
105
+ };
106
+
107
+ export type CursorV1 = {
108
+ from: number;
109
+ };
110
+
111
+ export type PaginationParams = {
112
+ cursor?: CursorV1;
113
+ size?: number;
114
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "./dist/types",
5
+ "rootDir": "./src",
6
+ "declaration": true
7
+ }
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/esm",
5
+ "declarationDir": "./dist/types",
6
+ "module": "ES6",
7
+ "target": "es6",
8
+ "rootDir": "./src",
9
+ "declaration": true,
10
+ "declarationMap": true
11
+ }
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/cjs",
5
+ "rootDir": "./src"
6
+ }
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "./dist/types",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "emitDeclarationOnly": true
9
+ }
10
+ }