@datocms/cma-client 1.1.5 → 1.1.7
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/dist/cjs/generated/resources/Workflow.js +2 -2
- package/dist/cjs/generated/resources/Workflow.js.map +1 -1
- package/dist/cjs/generated/resources/index.js +1 -1
- package/dist/cjs/generated/resources/index.js.map +1 -1
- package/dist/cjs/resources/Role.js +166 -0
- package/dist/cjs/resources/Role.js.map +1 -0
- package/dist/esm/generated/SchemaTypes.d.ts +12 -1
- package/dist/esm/generated/SimpleSchemaTypes.d.ts +16 -1
- package/dist/esm/generated/resources/Workflow.js +2 -2
- package/dist/esm/generated/resources/Workflow.js.map +1 -1
- package/dist/esm/generated/resources/index.d.ts +1 -1
- package/dist/esm/generated/resources/index.js +1 -1
- package/dist/esm/generated/resources/index.js.map +1 -1
- package/dist/esm/resources/Role.d.ts +21 -0
- package/dist/esm/resources/Role.js +161 -0
- package/dist/esm/resources/Role.js.map +1 -0
- package/dist/types/generated/SchemaTypes.d.ts +12 -1
- package/dist/types/generated/SimpleSchemaTypes.d.ts +16 -1
- package/dist/types/generated/resources/index.d.ts +1 -1
- package/dist/types/resources/Role.d.ts +21 -0
- package/package.json +2 -2
- package/resources.json +2 -0
- package/src/generated/SchemaTypes.ts +12 -1
- package/src/generated/SimpleSchemaTypes.ts +16 -1
- package/src/generated/resources/Workflow.ts +2 -2
- package/src/generated/resources/index.ts +1 -1
- package/src/resources/Role.ts +155 -0
|
@@ -59,7 +59,7 @@ var Workflow = /** @class */ (function (_super) {
|
|
|
59
59
|
Workflow.prototype.create = function (body) {
|
|
60
60
|
return this.rawCreate(Utils.serializeRequestBody(body, {
|
|
61
61
|
type: 'workflow',
|
|
62
|
-
attributes: ['name', 'stages'],
|
|
62
|
+
attributes: ['name', 'api_key', 'stages'],
|
|
63
63
|
relationships: [],
|
|
64
64
|
})).then(function (body) {
|
|
65
65
|
return Utils.deserializeResponseBody(body);
|
|
@@ -92,7 +92,7 @@ var Workflow = /** @class */ (function (_super) {
|
|
|
92
92
|
return this.rawUpdate(Utils.toId(workflowId), Utils.serializeRequestBody(body, {
|
|
93
93
|
id: Utils.toId(workflowId),
|
|
94
94
|
type: 'workflow',
|
|
95
|
-
attributes: ['name', 'stages'],
|
|
95
|
+
attributes: ['name', 'api_key', 'stages'],
|
|
96
96
|
relationships: [],
|
|
97
97
|
})).then(function (body) {
|
|
98
98
|
return Utils.deserializeResponseBody(body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.js","sourceRoot":"","sources":["../../../../src/generated/resources/Workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAoD;AAGpD,oEAA8C;AAE9C;IAAsC,4BAAY;IAAlD;;IAiLA,CAAC;IA9KC;;;;;;;OAOG;IACH,yBAAM,GAAN,UAAO,IAA4C;QACjD,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,oBAAoB,CAAmC,IAAI,EAAE;YACjE,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Workflow.js","sourceRoot":"","sources":["../../../../src/generated/resources/Workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAoD;AAGpD,oEAA8C;AAE9C;IAAsC,4BAAY;IAAlD;;IAiLA,CAAC;IA9KC;;;;;;;OAOG;IACH,yBAAM,GAAN,UAAO,IAA4C;QACjD,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,oBAAoB,CAAmC,IAAI,EAAE;YACjE,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC;YACzC,aAAa,EAAE,EAAE;SAClB,CAAC,CACH,CAAC,IAAI,CAAC,UAAC,IAAI;YACV,O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AA4C;YACpE,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,YAAY;SAClB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,uBAAI,GAAJ,UAAK,UAAmD;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,IAAI;YACpD,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,0BAAO,GAAP,UAAQ,UAAkB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAuC;YAC/D,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,qBAAc,UAAU,CAAE;SAChC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,0BAAO,GAAP,UAAQ,UAAmD;QACzD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACH,6BAAU,GAAV,UAAW,UAAkB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAO;YAC/B,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,qBAAc,UAAU,CAAE;SAChC,CAAC,CAAC;IACL,CAAC;IA/Ke,aAAI,GAAe,UAAU,CAAC;IAgLhD,eAAC;CAAA,AAjLD,CAAsC,sBAAY,GAiLjD;kBAjLoB,QAAQ"}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Workflow = exports.Site = exports.UploadSmartTag = exports.UploadTag = exports.UsageCounter = exports.DailyUsage = exports.PublicInfo = exports.WhiteLabelSettings = exports.SsoSettings = exports.SsoGroup = exports.EditingSession = exports.SiteInvitation = exports.UploadFilter = exports.ItemTypeFilter = exports.BuildTrigger = exports.WebhookCall = exports.Webhook = exports.MaintenanceMode = exports.Environment = exports.SearchResult = exports.ScheduledUnpublishing = exports.ScheduledPublication = exports.UploadRequest = exports.Upload = exports.ItemVersion = exports.Item = exports.BuildEvent = exports.SubscriptionFeature = exports.SubscriptionLimit = exports.JobResult = exports.Plugin = exports.AccessToken = exports.Session = exports.Fieldset = exports.Field = exports.ItemType = exports.MenuItem = exports.AuditLogEvent = exports.SsoUser = exports.User = exports.Role = void 0;
|
|
7
|
-
var Role_1 = require("
|
|
7
|
+
var Role_1 = require("../../resources/Role");
|
|
8
8
|
Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return __importDefault(Role_1).default; } });
|
|
9
9
|
var User_1 = require("./User");
|
|
10
10
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return __importDefault(User_1).default; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/resources/index.ts"],"names":[],"mappings":";;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/resources/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAuD;AAA9C,6GAAA,OAAO,OAAQ;AACxB,+BAAyC;AAAhC,6GAAA,OAAO,OAAQ;AACxB,qCAA+C;AAAtC,mHAAA,OAAO,OAAW;AAC3B,iDAA2D;AAAlD,+HAAA,OAAO,OAAiB;AACjC,uCAAiD;AAAxC,qHAAA,OAAO,OAAY;AAC5B,uCAAiD;AAAxC,qHAAA,OAAO,OAAY;AAC5B,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,uCAAiD;AAAxC,qHAAA,OAAO,OAAY;AAC5B,qCAA+C;AAAtC,mHAAA,OAAO,OAAW;AAC3B,6CAAuD;AAA9C,2HAAA,OAAO,OAAe;AAC/B,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,yCAAmD;AAA1C,uHAAA,OA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@@ -0,0 +1,166 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
73
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
74
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
75
|
+
};
|
|
76
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
+
var Role_1 = __importDefault(require("../generated/resources/Role"));
|
|
78
|
+
function sameValue(a, b) {
|
|
79
|
+
if ((a === undefined || a === null) && (b === undefined || b === null)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return a === b;
|
|
83
|
+
}
|
|
84
|
+
function sameRule(obj1, obj2) {
|
|
85
|
+
for (var key in Object.keys(obj1)) {
|
|
86
|
+
if (!sameValue(obj1[key], obj2[key]))
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
for (var key in Object.keys(obj2)) {
|
|
90
|
+
if (!sameValue(obj1[key], obj2[key]))
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
function applyChanges(currentRules, changes, currentEnvironmentId, context) {
|
|
96
|
+
if (!changes) {
|
|
97
|
+
return currentRules;
|
|
98
|
+
}
|
|
99
|
+
var rulesToAdd = changes.add, rulesToRemove = changes.remove;
|
|
100
|
+
return __spreadArray(__spreadArray([], (rulesToRemove
|
|
101
|
+
? rulesToRemove.reduce(function (filteredRules, ruleToRemove) {
|
|
102
|
+
var ruleToRemoveWithEnvironmentId = __assign(__assign({}, ruleToRemove), { environment: currentEnvironmentId });
|
|
103
|
+
var foundRule = filteredRules.find(function (rule) {
|
|
104
|
+
return sameRule(rule, ruleToRemoveWithEnvironmentId);
|
|
105
|
+
});
|
|
106
|
+
if (!foundRule) {
|
|
107
|
+
throw new Error("Cannot find rule ".concat(JSON.stringify(ruleToRemoveWithEnvironmentId), " to remove in ").concat(context, "!"));
|
|
108
|
+
}
|
|
109
|
+
return filteredRules.filter(function (rule) { return rule !== foundRule; });
|
|
110
|
+
}, currentRules)
|
|
111
|
+
: currentRules), true), (rulesToAdd
|
|
112
|
+
? rulesToAdd.map(function (change) {
|
|
113
|
+
return (__assign({ environment: currentEnvironmentId }, change));
|
|
114
|
+
})
|
|
115
|
+
: []), true);
|
|
116
|
+
}
|
|
117
|
+
var RoleResource = /** @class */ (function (_super) {
|
|
118
|
+
__extends(RoleResource, _super);
|
|
119
|
+
function RoleResource() {
|
|
120
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Applies a set of changes to the permissions of the current environment
|
|
124
|
+
*/
|
|
125
|
+
RoleResource.prototype.updateCurrentEnvironmentPermissions = function (roleId, changes) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var currentEnvironmentId, _a, role, updateItemTypePermissions, updateUploadPermissions, body;
|
|
128
|
+
return __generator(this, function (_b) {
|
|
129
|
+
switch (_b.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
_a = this.client.config.environment;
|
|
132
|
+
if (_a) return [3 /*break*/, 2];
|
|
133
|
+
return [4 /*yield*/, this.client.environments.list()];
|
|
134
|
+
case 1:
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
136
|
+
_a = (_b.sent()).find(function (environment) { return environment.meta.primary; }).id;
|
|
137
|
+
_b.label = 2;
|
|
138
|
+
case 2:
|
|
139
|
+
currentEnvironmentId = _a;
|
|
140
|
+
return [4 /*yield*/, this.find(roleId)];
|
|
141
|
+
case 3:
|
|
142
|
+
role = _b.sent();
|
|
143
|
+
updateItemTypePermissions = Boolean(changes.positive_item_type_permissions ||
|
|
144
|
+
changes.negative_item_type_permissions);
|
|
145
|
+
updateUploadPermissions = Boolean(changes.positive_upload_permissions ||
|
|
146
|
+
changes.negative_upload_permissions);
|
|
147
|
+
body = __assign(__assign({}, (updateItemTypePermissions
|
|
148
|
+
? {
|
|
149
|
+
positive_item_type_permissions: applyChanges(role.positive_item_type_permissions, changes.positive_item_type_permissions, currentEnvironmentId, 'positive_item_type_permissions'),
|
|
150
|
+
negative_item_type_permissions: applyChanges(role.negative_item_type_permissions, changes.negative_item_type_permissions, currentEnvironmentId, 'negative_item_type_permissions'),
|
|
151
|
+
}
|
|
152
|
+
: {})), (updateUploadPermissions
|
|
153
|
+
? {
|
|
154
|
+
positive_upload_permissions: applyChanges(role.positive_upload_permissions, changes.positive_upload_permissions, currentEnvironmentId, 'positive_upload_permissions'),
|
|
155
|
+
negative_upload_permissions: applyChanges(role.negative_upload_permissions, changes.negative_upload_permissions, currentEnvironmentId, 'negative_upload_permissions'),
|
|
156
|
+
}
|
|
157
|
+
: {}));
|
|
158
|
+
return [2 /*return*/, this.update(roleId, body)];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
return RoleResource;
|
|
164
|
+
}(Role_1.default));
|
|
165
|
+
exports.default = RoleResource;
|
|
166
|
+
//# sourceMappingURL=Role.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../src/resources/Role.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAmD;AAqBnD,SAAS,SAAS,CAAC,CAAU,EAAE,CAAU;IACvC,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,S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oBAAoB,EACpB,gCAAgC,CACjC;gCACD,8BAA8B,EAAE,YAAY,CAC1C,IAAI,CAAC,8BAA8B,EACnC,OAAO,CAAC,8BAA8B,EACtC,oBAAoB,EACpB,gCAAgC,CACjC;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,uBAAuB;4BACzB,CAAC,CAAC;gCACE,2BAA2B,EAAE,YAAY,CACvC,IAAI,CAAC,2BAA2B,EAChC,OAAO,CAAC,2BAA2B,EACnC,oBAAoB,EACpB,6BAA6B,CAC9B;gCACD,2BAA2B,EAAE,YAAY,CACvC,IAAI,CAAC,2BAA2B,EAChC,OAAO,CAAC,2BAA2B,EACnC,oBAAoB,EACpB,6BAA6B,CAC9B;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC,CACR,CAAC;wBAEF,sBAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAC;;;;KAClC;IACH,mBAAC;AAAD,CAAC,AAhED,CAA0C,cAAQ,GAgEjD"}
|
|
@@ -9472,6 +9472,10 @@ export declare type WorkflowAttributes = {
|
|
|
9472
9472
|
* The name of the workflow
|
|
9473
9473
|
*/
|
|
9474
9474
|
name: string;
|
|
9475
|
+
/**
|
|
9476
|
+
* Workflow API key
|
|
9477
|
+
*/
|
|
9478
|
+
api_key: string;
|
|
9475
9479
|
/**
|
|
9476
9480
|
* The stages of the workflow
|
|
9477
9481
|
*/
|
|
@@ -9521,7 +9525,6 @@ export declare type WorkflowAttributes = {
|
|
|
9521
9525
|
export declare type WorkflowCreateSchema = {
|
|
9522
9526
|
data: {
|
|
9523
9527
|
type: WorkflowType;
|
|
9524
|
-
id: WorkflowIdentity;
|
|
9525
9528
|
/**
|
|
9526
9529
|
* JSON API attributes
|
|
9527
9530
|
*/
|
|
@@ -9530,6 +9533,10 @@ export declare type WorkflowCreateSchema = {
|
|
|
9530
9533
|
* The name of the workflow
|
|
9531
9534
|
*/
|
|
9532
9535
|
name: string;
|
|
9536
|
+
/**
|
|
9537
|
+
* Workflow API key
|
|
9538
|
+
*/
|
|
9539
|
+
api_key: string;
|
|
9533
9540
|
/**
|
|
9534
9541
|
* The stages of the workflow
|
|
9535
9542
|
*/
|
|
@@ -9597,6 +9604,10 @@ export declare type WorkflowUpdateSchema = {
|
|
|
9597
9604
|
* The name of the workflow
|
|
9598
9605
|
*/
|
|
9599
9606
|
name?: string;
|
|
9607
|
+
/**
|
|
9608
|
+
* Workflow API key
|
|
9609
|
+
*/
|
|
9610
|
+
api_key?: string;
|
|
9600
9611
|
/**
|
|
9601
9612
|
* The stages of the workflow
|
|
9602
9613
|
*/
|
|
@@ -9339,6 +9339,10 @@ export declare type Workflow = {
|
|
|
9339
9339
|
* The name of the workflow
|
|
9340
9340
|
*/
|
|
9341
9341
|
name: string;
|
|
9342
|
+
/**
|
|
9343
|
+
* Workflow API key
|
|
9344
|
+
*/
|
|
9345
|
+
api_key: string;
|
|
9342
9346
|
/**
|
|
9343
9347
|
* The stages of the workflow
|
|
9344
9348
|
*/
|
|
@@ -9395,6 +9399,10 @@ export declare type WorkflowAttributes = {
|
|
|
9395
9399
|
* The name of the workflow
|
|
9396
9400
|
*/
|
|
9397
9401
|
name: string;
|
|
9402
|
+
/**
|
|
9403
|
+
* Workflow API key
|
|
9404
|
+
*/
|
|
9405
|
+
api_key: string;
|
|
9398
9406
|
/**
|
|
9399
9407
|
* The stages of the workflow
|
|
9400
9408
|
*/
|
|
@@ -9442,12 +9450,15 @@ export declare type WorkflowAttributes = {
|
|
|
9442
9450
|
* via the `create.schema` link.
|
|
9443
9451
|
*/
|
|
9444
9452
|
export declare type WorkflowCreateSchema = {
|
|
9445
|
-
id?: WorkflowIdentity;
|
|
9446
9453
|
type?: WorkflowType;
|
|
9447
9454
|
/**
|
|
9448
9455
|
* The name of the workflow
|
|
9449
9456
|
*/
|
|
9450
9457
|
name: string;
|
|
9458
|
+
/**
|
|
9459
|
+
* Workflow API key
|
|
9460
|
+
*/
|
|
9461
|
+
api_key: string;
|
|
9451
9462
|
/**
|
|
9452
9463
|
* The stages of the workflow
|
|
9453
9464
|
*/
|
|
@@ -9501,6 +9512,10 @@ export declare type WorkflowUpdateSchema = {
|
|
|
9501
9512
|
* The name of the workflow
|
|
9502
9513
|
*/
|
|
9503
9514
|
name?: string;
|
|
9515
|
+
/**
|
|
9516
|
+
* Workflow API key
|
|
9517
|
+
*/
|
|
9518
|
+
api_key?: string;
|
|
9504
9519
|
/**
|
|
9505
9520
|
* The stages of the workflow
|
|
9506
9521
|
*/
|
|
@@ -31,7 +31,7 @@ var Workflow = /** @class */ (function (_super) {
|
|
|
31
31
|
Workflow.prototype.create = function (body) {
|
|
32
32
|
return this.rawCreate(Utils.serializeRequestBody(body, {
|
|
33
33
|
type: 'workflow',
|
|
34
|
-
attributes: ['name', 'stages'],
|
|
34
|
+
attributes: ['name', 'api_key', 'stages'],
|
|
35
35
|
relationships: [],
|
|
36
36
|
})).then(function (body) {
|
|
37
37
|
return Utils.deserializeResponseBody(body);
|
|
@@ -64,7 +64,7 @@ var Workflow = /** @class */ (function (_super) {
|
|
|
64
64
|
return this.rawUpdate(Utils.toId(workflowId), Utils.serializeRequestBody(body, {
|
|
65
65
|
id: Utils.toId(workflowId),
|
|
66
66
|
type: 'workflow',
|
|
67
|
-
attributes: ['name', 'stages'],
|
|
67
|
+
attributes: ['name', 'api_key', 'stages'],
|
|
68
68
|
relationships: [],
|
|
69
69
|
})).then(function (body) {
|
|
70
70
|
return Utils.deserializeResponseBody(body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.js","sourceRoot":"","sources":["../../../../src/generated/resources/Workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C;IAAsC,4BAAY;IAAlD;;IAiLA,CAAC;IA9KC;;;;;;;OAOG;IACH,yBAAM,GAAN,UAAO,IAA4C;QACjD,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,oBAAoB,CAAmC,IAAI,EAAE;YACjE,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Workflow.js","sourceRoot":"","sources":["../../../../src/generated/resources/Workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C;IAAsC,4BAAY;IAAlD;;IAiLA,CAAC;IA9KC;;;;;;;OAOG;IACH,yBAAM,GAAN,UAAO,IAA4C;QACjD,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,oBAAoB,CAAmC,IAAI,EAAE;YACjE,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC;YACzC,aAAa,EAAE,EAAE;SAClB,CAAC,CACH,CAAC,IAAI,CAAC,UAAC,IAAI;YACV,OAAA,KAAK,CAAC,uBAAuB,CAC3B,IAAI,CACL;QAFD,CAEC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,4BAAS,GAAT,UACE,IAAsC;QAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAyC;YACjE,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,YAAY;YACjB,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,yBAAM,GAAN,UACE,UAAmD,EACnD,IAA4C;QAE5C,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EACtB,KAAK,CAAC,oBAAoB,CAAmC,IAAI,EAAE;YACjE,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1B,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,CAAC,MAAM,EA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AmD;QACzD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACH,6BAAU,GAAV,UAAW,UAAkB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAO;YAC/B,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,qBAAc,UAAU,CAAE;SAChC,CAAC,CAAC;IACL,CAAC;IA/Ke,aAAI,GAAe,UAAU,CAAC;IAgLhD,eAAC;CAAA,AAjLD,CAAsC,YAAY,GAiLjD;eAjLoB,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,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E,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BaseRole from '../generated/resources/Role';
|
|
2
|
+
import * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
|
|
3
|
+
export declare type UpdateRoleDiff<T> = {
|
|
4
|
+
add?: Omit<T, 'environment'>[];
|
|
5
|
+
remove?: Omit<T, 'environment'>[];
|
|
6
|
+
};
|
|
7
|
+
export declare type RoleItemTypePermission = SimpleSchemaTypes.RoleAttributes['positive_item_type_permissions'][0];
|
|
8
|
+
export declare type RoleUploadPermission = SimpleSchemaTypes.RoleAttributes['positive_upload_permissions'][0];
|
|
9
|
+
declare type UpdateCurrentEnvironmentPermissionsChanges = {
|
|
10
|
+
positive_item_type_permissions?: UpdateRoleDiff<RoleItemTypePermission>;
|
|
11
|
+
negative_item_type_permissions?: UpdateRoleDiff<RoleItemTypePermission>;
|
|
12
|
+
positive_upload_permissions?: UpdateRoleDiff<RoleUploadPermission>;
|
|
13
|
+
negative_upload_permissions?: UpdateRoleDiff<RoleUploadPermission>;
|
|
14
|
+
};
|
|
15
|
+
export default class RoleResource extends BaseRole {
|
|
16
|
+
/**
|
|
17
|
+
* Applies a set of changes to the permissions of the current environment
|
|
18
|
+
*/
|
|
19
|
+
updateCurrentEnvironmentPermissions(roleId: string | SimpleSchemaTypes.RoleData, changes: UpdateCurrentEnvironmentPermissionsChanges): Promise<SimpleSchemaTypes.Role>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
37
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
39
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
40
|
+
function step(op) {
|
|
41
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
42
|
+
while (_) try {
|
|
43
|
+
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;
|
|
44
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
45
|
+
switch (op[0]) {
|
|
46
|
+
case 0: case 1: t = op; break;
|
|
47
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
48
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
49
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
50
|
+
default:
|
|
51
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
52
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
53
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
54
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
55
|
+
if (t[2]) _.ops.pop();
|
|
56
|
+
_.trys.pop(); continue;
|
|
57
|
+
}
|
|
58
|
+
op = body.call(thisArg, _);
|
|
59
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
60
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
64
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
65
|
+
if (ar || !(i in from)) {
|
|
66
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
67
|
+
ar[i] = from[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
71
|
+
};
|
|
72
|
+
import BaseRole from '../generated/resources/Role';
|
|
73
|
+
function sameValue(a, b) {
|
|
74
|
+
if ((a === undefined || a === null) && (b === undefined || b === null)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return a === b;
|
|
78
|
+
}
|
|
79
|
+
function sameRule(obj1, obj2) {
|
|
80
|
+
for (var key in Object.keys(obj1)) {
|
|
81
|
+
if (!sameValue(obj1[key], obj2[key]))
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
for (var key in Object.keys(obj2)) {
|
|
85
|
+
if (!sameValue(obj1[key], obj2[key]))
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
function applyChanges(currentRules, changes, currentEnvironmentId, context) {
|
|
91
|
+
if (!changes) {
|
|
92
|
+
return currentRules;
|
|
93
|
+
}
|
|
94
|
+
var rulesToAdd = changes.add, rulesToRemove = changes.remove;
|
|
95
|
+
return __spreadArray(__spreadArray([], (rulesToRemove
|
|
96
|
+
? rulesToRemove.reduce(function (filteredRules, ruleToRemove) {
|
|
97
|
+
var ruleToRemoveWithEnvironmentId = __assign(__assign({}, ruleToRemove), { environment: currentEnvironmentId });
|
|
98
|
+
var foundRule = filteredRules.find(function (rule) {
|
|
99
|
+
return sameRule(rule, ruleToRemoveWithEnvironmentId);
|
|
100
|
+
});
|
|
101
|
+
if (!foundRule) {
|
|
102
|
+
throw new Error("Cannot find rule ".concat(JSON.stringify(ruleToRemoveWithEnvironmentId), " to remove in ").concat(context, "!"));
|
|
103
|
+
}
|
|
104
|
+
return filteredRules.filter(function (rule) { return rule !== foundRule; });
|
|
105
|
+
}, currentRules)
|
|
106
|
+
: currentRules), true), (rulesToAdd
|
|
107
|
+
? rulesToAdd.map(function (change) {
|
|
108
|
+
return (__assign({ environment: currentEnvironmentId }, change));
|
|
109
|
+
})
|
|
110
|
+
: []), true);
|
|
111
|
+
}
|
|
112
|
+
var RoleResource = /** @class */ (function (_super) {
|
|
113
|
+
__extends(RoleResource, _super);
|
|
114
|
+
function RoleResource() {
|
|
115
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Applies a set of changes to the permissions of the current environment
|
|
119
|
+
*/
|
|
120
|
+
RoleResource.prototype.updateCurrentEnvironmentPermissions = function (roleId, changes) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var currentEnvironmentId, _a, role, updateItemTypePermissions, updateUploadPermissions, body;
|
|
123
|
+
return __generator(this, function (_b) {
|
|
124
|
+
switch (_b.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
_a = this.client.config.environment;
|
|
127
|
+
if (_a) return [3 /*break*/, 2];
|
|
128
|
+
return [4 /*yield*/, this.client.environments.list()];
|
|
129
|
+
case 1:
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
131
|
+
_a = (_b.sent()).find(function (environment) { return environment.meta.primary; }).id;
|
|
132
|
+
_b.label = 2;
|
|
133
|
+
case 2:
|
|
134
|
+
currentEnvironmentId = _a;
|
|
135
|
+
return [4 /*yield*/, this.find(roleId)];
|
|
136
|
+
case 3:
|
|
137
|
+
role = _b.sent();
|
|
138
|
+
updateItemTypePermissions = Boolean(changes.positive_item_type_permissions ||
|
|
139
|
+
changes.negative_item_type_permissions);
|
|
140
|
+
updateUploadPermissions = Boolean(changes.positive_upload_permissions ||
|
|
141
|
+
changes.negative_upload_permissions);
|
|
142
|
+
body = __assign(__assign({}, (updateItemTypePermissions
|
|
143
|
+
? {
|
|
144
|
+
positive_item_type_permissions: applyChanges(role.positive_item_type_permissions, changes.positive_item_type_permissions, currentEnvironmentId, 'positive_item_type_permissions'),
|
|
145
|
+
negative_item_type_permissions: applyChanges(role.negative_item_type_permissions, changes.negative_item_type_permissions, currentEnvironmentId, 'negative_item_type_permissions'),
|
|
146
|
+
}
|
|
147
|
+
: {})), (updateUploadPermissions
|
|
148
|
+
? {
|
|
149
|
+
positive_upload_permissions: applyChanges(role.positive_upload_permissions, changes.positive_upload_permissions, currentEnvironmentId, 'positive_upload_permissions'),
|
|
150
|
+
negative_upload_permissions: applyChanges(role.negative_upload_permissions, changes.negative_upload_permissions, currentEnvironmentId, 'negative_upload_permissions'),
|
|
151
|
+
}
|
|
152
|
+
: {}));
|
|
153
|
+
return [2 /*return*/, this.update(roleId, body)];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
return RoleResource;
|
|
159
|
+
}(BaseRole));
|
|
160
|
+
export default RoleResource;
|
|
161
|
+
//# sourceMappingURL=Role.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../src/resources/Role.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,GAAG,OAAO,CACrC,OAAO,CAAC,2BAA2B;4BACjC,OAAO,CAAC,2BAA2B,CACtC,CAAC;wBAEI,IAAI,yBACL,CAAC,yBAAyB;4BAC3B,CAAC,CAAC;gCACE,8BAA8B,EAAE,YAAY,CAC1C,IAAI,CAAC,8BAA8B,EACnC,OAAO,CAAC,8BAA8B,EACtC,oBAAoB,EACpB,gCAAgC,CACjC;gCACD,8BAA8B,EAAE,YAAY,CAC1C,IAAI,CAAC,8BAA8B,EACnC,OAAO,CAAC,8BAA8B,EACtC,oBAAoB,EACpB,gCAAgC,CACjC;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,uBAAuB;4BACzB,CAAC,CAAC;gCACE,2BAA2B,EAAE,YAAY,CACvC,IAAI,CAAC,2BAA2B,EAChC,OAAO,CAAC,2BAA2B,EACnC,oBAAoB,EACpB,6BAA6B,CAC9B;gCACD,2BAA2B,EAAE,YAAY,CACvC,IAAI,CAAC,2BAA2B,EAChC,OAAO,CAAC,2BAA2B,EACnC,oBAAoB,EACpB,6BAA6B,CAC9B;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC,CACR,CAAC;wBAEF,sBAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAC;;;;KAClC;IACH,mBAAC;AAAD,CAAC,AAhED,CAA0C,QAAQ,GAgEjD"}
|
|
@@ -9472,6 +9472,10 @@ export declare type WorkflowAttributes = {
|
|
|
9472
9472
|
* The name of the workflow
|
|
9473
9473
|
*/
|
|
9474
9474
|
name: string;
|
|
9475
|
+
/**
|
|
9476
|
+
* Workflow API key
|
|
9477
|
+
*/
|
|
9478
|
+
api_key: string;
|
|
9475
9479
|
/**
|
|
9476
9480
|
* The stages of the workflow
|
|
9477
9481
|
*/
|
|
@@ -9521,7 +9525,6 @@ export declare type WorkflowAttributes = {
|
|
|
9521
9525
|
export declare type WorkflowCreateSchema = {
|
|
9522
9526
|
data: {
|
|
9523
9527
|
type: WorkflowType;
|
|
9524
|
-
id: WorkflowIdentity;
|
|
9525
9528
|
/**
|
|
9526
9529
|
* JSON API attributes
|
|
9527
9530
|
*/
|
|
@@ -9530,6 +9533,10 @@ export declare type WorkflowCreateSchema = {
|
|
|
9530
9533
|
* The name of the workflow
|
|
9531
9534
|
*/
|
|
9532
9535
|
name: string;
|
|
9536
|
+
/**
|
|
9537
|
+
* Workflow API key
|
|
9538
|
+
*/
|
|
9539
|
+
api_key: string;
|
|
9533
9540
|
/**
|
|
9534
9541
|
* The stages of the workflow
|
|
9535
9542
|
*/
|
|
@@ -9597,6 +9604,10 @@ export declare type WorkflowUpdateSchema = {
|
|
|
9597
9604
|
* The name of the workflow
|
|
9598
9605
|
*/
|
|
9599
9606
|
name?: string;
|
|
9607
|
+
/**
|
|
9608
|
+
* Workflow API key
|
|
9609
|
+
*/
|
|
9610
|
+
api_key?: string;
|
|
9600
9611
|
/**
|
|
9601
9612
|
* The stages of the workflow
|
|
9602
9613
|
*/
|
|
@@ -9339,6 +9339,10 @@ export declare type Workflow = {
|
|
|
9339
9339
|
* The name of the workflow
|
|
9340
9340
|
*/
|
|
9341
9341
|
name: string;
|
|
9342
|
+
/**
|
|
9343
|
+
* Workflow API key
|
|
9344
|
+
*/
|
|
9345
|
+
api_key: string;
|
|
9342
9346
|
/**
|
|
9343
9347
|
* The stages of the workflow
|
|
9344
9348
|
*/
|
|
@@ -9395,6 +9399,10 @@ export declare type WorkflowAttributes = {
|
|
|
9395
9399
|
* The name of the workflow
|
|
9396
9400
|
*/
|
|
9397
9401
|
name: string;
|
|
9402
|
+
/**
|
|
9403
|
+
* Workflow API key
|
|
9404
|
+
*/
|
|
9405
|
+
api_key: string;
|
|
9398
9406
|
/**
|
|
9399
9407
|
* The stages of the workflow
|
|
9400
9408
|
*/
|
|
@@ -9442,12 +9450,15 @@ export declare type WorkflowAttributes = {
|
|
|
9442
9450
|
* via the `create.schema` link.
|
|
9443
9451
|
*/
|
|
9444
9452
|
export declare type WorkflowCreateSchema = {
|
|
9445
|
-
id?: WorkflowIdentity;
|
|
9446
9453
|
type?: WorkflowType;
|
|
9447
9454
|
/**
|
|
9448
9455
|
* The name of the workflow
|
|
9449
9456
|
*/
|
|
9450
9457
|
name: string;
|
|
9458
|
+
/**
|
|
9459
|
+
* Workflow API key
|
|
9460
|
+
*/
|
|
9461
|
+
api_key: string;
|
|
9451
9462
|
/**
|
|
9452
9463
|
* The stages of the workflow
|
|
9453
9464
|
*/
|
|
@@ -9501,6 +9512,10 @@ export declare type WorkflowUpdateSchema = {
|
|
|
9501
9512
|
* The name of the workflow
|
|
9502
9513
|
*/
|
|
9503
9514
|
name?: string;
|
|
9515
|
+
/**
|
|
9516
|
+
* Workflow API key
|
|
9517
|
+
*/
|
|
9518
|
+
api_key?: string;
|
|
9504
9519
|
/**
|
|
9505
9520
|
* The stages of the workflow
|
|
9506
9521
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BaseRole from '../generated/resources/Role';
|
|
2
|
+
import * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
|
|
3
|
+
export declare type UpdateRoleDiff<T> = {
|
|
4
|
+
add?: Omit<T, 'environment'>[];
|
|
5
|
+
remove?: Omit<T, 'environment'>[];
|
|
6
|
+
};
|
|
7
|
+
export declare type RoleItemTypePermission = SimpleSchemaTypes.RoleAttributes['positive_item_type_permissions'][0];
|
|
8
|
+
export declare type RoleUploadPermission = SimpleSchemaTypes.RoleAttributes['positive_upload_permissions'][0];
|
|
9
|
+
declare type UpdateCurrentEnvironmentPermissionsChanges = {
|
|
10
|
+
positive_item_type_permissions?: UpdateRoleDiff<RoleItemTypePermission>;
|
|
11
|
+
negative_item_type_permissions?: UpdateRoleDiff<RoleItemTypePermission>;
|
|
12
|
+
positive_upload_permissions?: UpdateRoleDiff<RoleUploadPermission>;
|
|
13
|
+
negative_upload_permissions?: UpdateRoleDiff<RoleUploadPermission>;
|
|
14
|
+
};
|
|
15
|
+
export default class RoleResource extends BaseRole {
|
|
16
|
+
/**
|
|
17
|
+
* Applies a set of changes to the permissions of the current environment
|
|
18
|
+
*/
|
|
19
|
+
updateCurrentEnvironmentPermissions(roleId: string | SimpleSchemaTypes.RoleData, changes: UpdateCurrentEnvironmentPermissionsChanges): Promise<SimpleSchemaTypes.Role>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datocms/cma-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "JS client for DatoCMS REST Content Management API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@datocms/dashboard-client": "^1.1.5"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "73df11fe0f485d81d8a081d944f43eb55dac00a7"
|
|
46
46
|
}
|
package/resources.json
CHANGED
|
@@ -3312,6 +3312,7 @@
|
|
|
3312
3312
|
"type": "workflow",
|
|
3313
3313
|
"attributes": [
|
|
3314
3314
|
"name",
|
|
3315
|
+
"api_key",
|
|
3315
3316
|
"stages"
|
|
3316
3317
|
],
|
|
3317
3318
|
"relationships": []
|
|
@@ -3338,6 +3339,7 @@
|
|
|
3338
3339
|
"type": "workflow",
|
|
3339
3340
|
"attributes": [
|
|
3340
3341
|
"name",
|
|
3342
|
+
"api_key",
|
|
3341
3343
|
"stages"
|
|
3342
3344
|
],
|
|
3343
3345
|
"relationships": []
|
|
@@ -10104,6 +10104,10 @@ export type WorkflowAttributes = {
|
|
|
10104
10104
|
* The name of the workflow
|
|
10105
10105
|
*/
|
|
10106
10106
|
name: string;
|
|
10107
|
+
/**
|
|
10108
|
+
* Workflow API key
|
|
10109
|
+
*/
|
|
10110
|
+
api_key: string;
|
|
10107
10111
|
/**
|
|
10108
10112
|
* The stages of the workflow
|
|
10109
10113
|
*/
|
|
@@ -10154,7 +10158,6 @@ export type WorkflowAttributes = {
|
|
|
10154
10158
|
export type WorkflowCreateSchema = {
|
|
10155
10159
|
data: {
|
|
10156
10160
|
type: WorkflowType;
|
|
10157
|
-
id: WorkflowIdentity;
|
|
10158
10161
|
/**
|
|
10159
10162
|
* JSON API attributes
|
|
10160
10163
|
*/
|
|
@@ -10163,6 +10166,10 @@ export type WorkflowCreateSchema = {
|
|
|
10163
10166
|
* The name of the workflow
|
|
10164
10167
|
*/
|
|
10165
10168
|
name: string;
|
|
10169
|
+
/**
|
|
10170
|
+
* Workflow API key
|
|
10171
|
+
*/
|
|
10172
|
+
api_key: string;
|
|
10166
10173
|
/**
|
|
10167
10174
|
* The stages of the workflow
|
|
10168
10175
|
*/
|
|
@@ -10232,6 +10239,10 @@ export type WorkflowUpdateSchema = {
|
|
|
10232
10239
|
* The name of the workflow
|
|
10233
10240
|
*/
|
|
10234
10241
|
name?: string;
|
|
10242
|
+
/**
|
|
10243
|
+
* Workflow API key
|
|
10244
|
+
*/
|
|
10245
|
+
api_key?: string;
|
|
10235
10246
|
/**
|
|
10236
10247
|
* The stages of the workflow
|
|
10237
10248
|
*/
|
|
@@ -9837,6 +9837,10 @@ export type Workflow = {
|
|
|
9837
9837
|
* The name of the workflow
|
|
9838
9838
|
*/
|
|
9839
9839
|
name: string;
|
|
9840
|
+
/**
|
|
9841
|
+
* Workflow API key
|
|
9842
|
+
*/
|
|
9843
|
+
api_key: string;
|
|
9840
9844
|
/**
|
|
9841
9845
|
* The stages of the workflow
|
|
9842
9846
|
*/
|
|
@@ -9893,6 +9897,10 @@ export type WorkflowAttributes = {
|
|
|
9893
9897
|
* The name of the workflow
|
|
9894
9898
|
*/
|
|
9895
9899
|
name: string;
|
|
9900
|
+
/**
|
|
9901
|
+
* Workflow API key
|
|
9902
|
+
*/
|
|
9903
|
+
api_key: string;
|
|
9896
9904
|
/**
|
|
9897
9905
|
* The stages of the workflow
|
|
9898
9906
|
*/
|
|
@@ -9941,12 +9949,15 @@ export type WorkflowAttributes = {
|
|
|
9941
9949
|
* via the `create.schema` link.
|
|
9942
9950
|
*/
|
|
9943
9951
|
export type WorkflowCreateSchema = {
|
|
9944
|
-
id?: WorkflowIdentity;
|
|
9945
9952
|
type?: WorkflowType;
|
|
9946
9953
|
/**
|
|
9947
9954
|
* The name of the workflow
|
|
9948
9955
|
*/
|
|
9949
9956
|
name: string;
|
|
9957
|
+
/**
|
|
9958
|
+
* Workflow API key
|
|
9959
|
+
*/
|
|
9960
|
+
api_key: string;
|
|
9950
9961
|
/**
|
|
9951
9962
|
* The stages of the workflow
|
|
9952
9963
|
*/
|
|
@@ -10001,6 +10012,10 @@ export type WorkflowUpdateSchema = {
|
|
|
10001
10012
|
* The name of the workflow
|
|
10002
10013
|
*/
|
|
10003
10014
|
name?: string;
|
|
10015
|
+
/**
|
|
10016
|
+
* Workflow API key
|
|
10017
|
+
*/
|
|
10018
|
+
api_key?: string;
|
|
10004
10019
|
/**
|
|
10005
10020
|
* The stages of the workflow
|
|
10006
10021
|
*/
|
|
@@ -18,7 +18,7 @@ export default class Workflow extends BaseResource {
|
|
|
18
18
|
return this.rawCreate(
|
|
19
19
|
Utils.serializeRequestBody<SchemaTypes.WorkflowCreateSchema>(body, {
|
|
20
20
|
type: 'workflow',
|
|
21
|
-
attributes: ['name', 'stages'],
|
|
21
|
+
attributes: ['name', 'api_key', 'stages'],
|
|
22
22
|
relationships: [],
|
|
23
23
|
}),
|
|
24
24
|
).then((body) =>
|
|
@@ -63,7 +63,7 @@ export default class Workflow extends BaseResource {
|
|
|
63
63
|
Utils.serializeRequestBody<SchemaTypes.WorkflowUpdateSchema>(body, {
|
|
64
64
|
id: Utils.toId(workflowId),
|
|
65
65
|
type: 'workflow',
|
|
66
|
-
attributes: ['name', 'stages'],
|
|
66
|
+
attributes: ['name', 'api_key', 'stages'],
|
|
67
67
|
relationships: [],
|
|
68
68
|
}),
|
|
69
69
|
).then((body) =>
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import BaseRole from '../generated/resources/Role';
|
|
2
|
+
import * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
|
|
3
|
+
|
|
4
|
+
export type UpdateRoleDiff<T> = {
|
|
5
|
+
add?: Omit<T, 'environment'>[];
|
|
6
|
+
remove?: Omit<T, 'environment'>[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type RoleItemTypePermission =
|
|
10
|
+
SimpleSchemaTypes.RoleAttributes['positive_item_type_permissions'][0];
|
|
11
|
+
|
|
12
|
+
export type RoleUploadPermission =
|
|
13
|
+
SimpleSchemaTypes.RoleAttributes['positive_upload_permissions'][0];
|
|
14
|
+
|
|
15
|
+
type UpdateCurrentEnvironmentPermissionsChanges = {
|
|
16
|
+
positive_item_type_permissions?: UpdateRoleDiff<RoleItemTypePermission>;
|
|
17
|
+
negative_item_type_permissions?: UpdateRoleDiff<RoleItemTypePermission>;
|
|
18
|
+
positive_upload_permissions?: UpdateRoleDiff<RoleUploadPermission>;
|
|
19
|
+
negative_upload_permissions?: UpdateRoleDiff<RoleUploadPermission>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function sameValue(a: unknown, b: unknown) {
|
|
23
|
+
if ((a === undefined || a === null) && (b === undefined || b === null)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return a === b;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function sameRule(
|
|
30
|
+
obj1: Record<string, unknown>,
|
|
31
|
+
obj2: Record<string, unknown>,
|
|
32
|
+
): boolean {
|
|
33
|
+
for (const key in Object.keys(obj1)) {
|
|
34
|
+
if (!sameValue(obj1[key], obj2[key])) return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const key in Object.keys(obj2)) {
|
|
38
|
+
if (!sameValue(obj1[key], obj2[key])) return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function applyChanges<T extends Record<PropertyKey, unknown>>(
|
|
45
|
+
currentRules: T[],
|
|
46
|
+
changes: UpdateRoleDiff<T> | undefined,
|
|
47
|
+
currentEnvironmentId: string,
|
|
48
|
+
context: string,
|
|
49
|
+
): T[] {
|
|
50
|
+
if (!changes) {
|
|
51
|
+
return currentRules;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { add: rulesToAdd, remove: rulesToRemove } = changes;
|
|
55
|
+
|
|
56
|
+
return [
|
|
57
|
+
...(rulesToRemove
|
|
58
|
+
? rulesToRemove.reduce((filteredRules, ruleToRemove) => {
|
|
59
|
+
const ruleToRemoveWithEnvironmentId = {
|
|
60
|
+
...ruleToRemove,
|
|
61
|
+
environment: currentEnvironmentId,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const foundRule = filteredRules.find((rule) =>
|
|
65
|
+
sameRule(rule, ruleToRemoveWithEnvironmentId),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (!foundRule) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`Cannot find rule ${JSON.stringify(
|
|
71
|
+
ruleToRemoveWithEnvironmentId,
|
|
72
|
+
)} to remove in ${context}!`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return filteredRules.filter((rule) => rule !== foundRule);
|
|
77
|
+
}, currentRules)
|
|
78
|
+
: currentRules),
|
|
79
|
+
...(rulesToAdd
|
|
80
|
+
? rulesToAdd.map(
|
|
81
|
+
(change) =>
|
|
82
|
+
({
|
|
83
|
+
environment: currentEnvironmentId,
|
|
84
|
+
...change,
|
|
85
|
+
} as unknown as T),
|
|
86
|
+
)
|
|
87
|
+
: []),
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default class RoleResource extends BaseRole {
|
|
92
|
+
/**
|
|
93
|
+
* Applies a set of changes to the permissions of the current environment
|
|
94
|
+
*/
|
|
95
|
+
async updateCurrentEnvironmentPermissions(
|
|
96
|
+
roleId: string | SimpleSchemaTypes.RoleData,
|
|
97
|
+
changes: UpdateCurrentEnvironmentPermissionsChanges,
|
|
98
|
+
): Promise<SimpleSchemaTypes.Role> {
|
|
99
|
+
const currentEnvironmentId =
|
|
100
|
+
this.client.config.environment ||
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
102
|
+
(await this.client.environments.list()).find(
|
|
103
|
+
(environment) => environment.meta.primary,
|
|
104
|
+
)!.id;
|
|
105
|
+
|
|
106
|
+
const role = await this.find(roleId);
|
|
107
|
+
|
|
108
|
+
const updateItemTypePermissions = Boolean(
|
|
109
|
+
changes.positive_item_type_permissions ||
|
|
110
|
+
changes.negative_item_type_permissions,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const updateUploadPermissions = Boolean(
|
|
114
|
+
changes.positive_upload_permissions ||
|
|
115
|
+
changes.negative_upload_permissions,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const body: SimpleSchemaTypes.RoleUpdateSchema = {
|
|
119
|
+
...(updateItemTypePermissions
|
|
120
|
+
? {
|
|
121
|
+
positive_item_type_permissions: applyChanges(
|
|
122
|
+
role.positive_item_type_permissions,
|
|
123
|
+
changes.positive_item_type_permissions,
|
|
124
|
+
currentEnvironmentId,
|
|
125
|
+
'positive_item_type_permissions',
|
|
126
|
+
),
|
|
127
|
+
negative_item_type_permissions: applyChanges(
|
|
128
|
+
role.negative_item_type_permissions,
|
|
129
|
+
changes.negative_item_type_permissions,
|
|
130
|
+
currentEnvironmentId,
|
|
131
|
+
'negative_item_type_permissions',
|
|
132
|
+
),
|
|
133
|
+
}
|
|
134
|
+
: {}),
|
|
135
|
+
...(updateUploadPermissions
|
|
136
|
+
? {
|
|
137
|
+
positive_upload_permissions: applyChanges(
|
|
138
|
+
role.positive_upload_permissions,
|
|
139
|
+
changes.positive_upload_permissions,
|
|
140
|
+
currentEnvironmentId,
|
|
141
|
+
'positive_upload_permissions',
|
|
142
|
+
),
|
|
143
|
+
negative_upload_permissions: applyChanges(
|
|
144
|
+
role.negative_upload_permissions,
|
|
145
|
+
changes.negative_upload_permissions,
|
|
146
|
+
currentEnvironmentId,
|
|
147
|
+
'negative_upload_permissions',
|
|
148
|
+
),
|
|
149
|
+
}
|
|
150
|
+
: {}),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return this.update(roleId, body);
|
|
154
|
+
}
|
|
155
|
+
}
|