@workos-inc/node 7.76.0 → 7.79.2
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/lib/feature-flags/feature-flags.d.ts +13 -0
- package/lib/feature-flags/feature-flags.js +56 -0
- package/lib/feature-flags/feature-flags.spec.d.ts +1 -0
- package/lib/feature-flags/feature-flags.spec.js +173 -0
- package/lib/feature-flags/fixtures/disable-feature-flag.json +12 -0
- package/lib/feature-flags/fixtures/enable-feature-flag.json +12 -0
- package/lib/feature-flags/fixtures/get-feature-flag.json +12 -0
- package/lib/feature-flags/fixtures/list-feature-flags.json +45 -0
- package/lib/feature-flags/interfaces/add-flag-target-options.interface.d.ts +4 -0
- package/lib/feature-flags/interfaces/add-flag-target-options.interface.js +2 -0
- package/lib/feature-flags/interfaces/feature-flag.interface.d.ts +8 -2
- package/lib/feature-flags/interfaces/index.d.ts +3 -0
- package/lib/feature-flags/interfaces/index.js +3 -0
- package/lib/feature-flags/interfaces/list-feature-flags-options.interface.d.ts +2 -0
- package/lib/feature-flags/interfaces/list-feature-flags-options.interface.js +2 -0
- package/lib/feature-flags/interfaces/remove-flag-target-options.interface.d.ts +4 -0
- package/lib/feature-flags/interfaces/remove-flag-target-options.interface.js +2 -0
- package/lib/feature-flags/serializers/feature-flag.serializer.js +3 -0
- package/lib/feature-flags/serializers/index.d.ts +1 -0
- package/lib/feature-flags/serializers/index.js +17 -0
- package/lib/organizations/fixtures/list-organization-feature-flags.json +10 -1
- package/lib/organizations/organizations.js +2 -2
- package/lib/organizations/organizations.spec.js +10 -1
- package/lib/pipes/fixtures/get-access-token-needs-reauth.json +4 -0
- package/lib/pipes/fixtures/get-access-token-no-expiry.json +10 -0
- package/lib/pipes/fixtures/get-access-token-not-installed.json +4 -0
- package/lib/pipes/fixtures/get-access-token-success.json +10 -0
- package/lib/pipes/interfaces/access-token.interface.d.ts +14 -0
- package/lib/pipes/interfaces/access-token.interface.js +2 -0
- package/lib/pipes/interfaces/get-access-token.interface.d.ts +27 -0
- package/lib/pipes/interfaces/get-access-token.interface.js +2 -0
- package/lib/pipes/pipes.d.ts +9 -0
- package/lib/pipes/pipes.js +37 -0
- package/lib/pipes/pipes.spec.d.ts +1 -0
- package/lib/pipes/pipes.spec.js +109 -0
- package/lib/pipes/serializers/access-token.serializer.d.ts +2 -0
- package/lib/pipes/serializers/access-token.serializer.js +15 -0
- package/lib/pipes/serializers/get-access-token.serializer.d.ts +3 -0
- package/lib/pipes/serializers/get-access-token.serializer.js +24 -0
- package/lib/user-management/fixtures/list-user-feature-flags.json +10 -1
- package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.d.ts +3 -2
- package/lib/user-management/session.js +2 -0
- package/lib/user-management/user-management.js +42 -40
- package/lib/user-management/user-management.spec.js +10 -1
- package/lib/vault/vault-live-test.spec.js +33 -4
- package/lib/vault/vault.d.ts +1 -0
- package/lib/vault/vault.js +6 -0
- package/lib/vault/vault.spec.js +25 -0
- package/lib/workos.d.ts +9 -5
- package/lib/workos.js +9 -5
- package/package.json +4 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AutoPaginatable } from '../common/utils/pagination';
|
|
2
|
+
import { WorkOS } from '../workos';
|
|
3
|
+
import { AddFlagTargetOptions, FeatureFlag, ListFeatureFlagsOptions, RemoveFlagTargetOptions } from './interfaces';
|
|
4
|
+
export declare class FeatureFlags {
|
|
5
|
+
private readonly workos;
|
|
6
|
+
constructor(workos: WorkOS);
|
|
7
|
+
listFeatureFlags(options?: ListFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag>>;
|
|
8
|
+
getFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
9
|
+
enableFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
10
|
+
disableFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
11
|
+
addFlagTarget(options: AddFlagTargetOptions): Promise<void>;
|
|
12
|
+
removeFlagTarget(options: RemoveFlagTargetOptions): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FeatureFlags = void 0;
|
|
13
|
+
const pagination_1 = require("../common/utils/pagination");
|
|
14
|
+
const serializers_1 = require("./serializers");
|
|
15
|
+
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
16
|
+
class FeatureFlags {
|
|
17
|
+
constructor(workos) {
|
|
18
|
+
this.workos = workos;
|
|
19
|
+
}
|
|
20
|
+
listFeatureFlags(options) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/feature-flags', serializers_1.deserializeFeatureFlag, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/feature-flags', serializers_1.deserializeFeatureFlag, params), options);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getFeatureFlag(slug) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const { data } = yield this.workos.get(`/feature-flags/${slug}`);
|
|
28
|
+
return (0, serializers_1.deserializeFeatureFlag)(data);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
enableFeatureFlag(slug) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const { data } = yield this.workos.put(`/feature-flags/${slug}/enable`, {});
|
|
34
|
+
return (0, serializers_1.deserializeFeatureFlag)(data);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
disableFeatureFlag(slug) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { data } = yield this.workos.put(`/feature-flags/${slug}/disable`, {});
|
|
40
|
+
return (0, serializers_1.deserializeFeatureFlag)(data);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
addFlagTarget(options) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const { slug, targetId } = options;
|
|
46
|
+
yield this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
removeFlagTarget(options) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { slug, targetId } = options;
|
|
52
|
+
yield this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.FeatureFlags = FeatureFlags;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
|
|
16
|
+
const test_utils_1 = require("../common/utils/test-utils");
|
|
17
|
+
const workos_1 = require("../workos");
|
|
18
|
+
const list_feature_flags_json_1 = __importDefault(require("./fixtures/list-feature-flags.json"));
|
|
19
|
+
const get_feature_flag_json_1 = __importDefault(require("./fixtures/get-feature-flag.json"));
|
|
20
|
+
const enable_feature_flag_json_1 = __importDefault(require("./fixtures/enable-feature-flag.json"));
|
|
21
|
+
const disable_feature_flag_json_1 = __importDefault(require("./fixtures/disable-feature-flag.json"));
|
|
22
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
23
|
+
describe('FeatureFlags', () => {
|
|
24
|
+
beforeEach(() => jest_fetch_mock_1.default.resetMocks());
|
|
25
|
+
describe('listFeatureFlags', () => {
|
|
26
|
+
describe('without any options', () => {
|
|
27
|
+
it('returns feature flags and metadata', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
(0, test_utils_1.fetchOnce)(list_feature_flags_json_1.default);
|
|
29
|
+
const { data, listMetadata } = yield workos.featureFlags.listFeatureFlags();
|
|
30
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
31
|
+
order: 'desc',
|
|
32
|
+
});
|
|
33
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags');
|
|
34
|
+
expect(data).toHaveLength(3);
|
|
35
|
+
expect(data[0]).toEqual({
|
|
36
|
+
object: 'feature_flag',
|
|
37
|
+
id: 'flag_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
38
|
+
name: 'Advanced Dashboard',
|
|
39
|
+
slug: 'advanced-dashboard',
|
|
40
|
+
description: 'Enable advanced dashboard features',
|
|
41
|
+
tags: ['ui'],
|
|
42
|
+
enabled: true,
|
|
43
|
+
defaultValue: false,
|
|
44
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
45
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
46
|
+
});
|
|
47
|
+
expect(listMetadata).toEqual({
|
|
48
|
+
before: null,
|
|
49
|
+
after: 'flag_01EHQMYV6MBK39QC5PZXHY59C7',
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
describe('with the before option', () => {
|
|
54
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
(0, test_utils_1.fetchOnce)(list_feature_flags_json_1.default);
|
|
56
|
+
const { data } = yield workos.featureFlags.listFeatureFlags({
|
|
57
|
+
before: 'flag_before_id',
|
|
58
|
+
});
|
|
59
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
60
|
+
before: 'flag_before_id',
|
|
61
|
+
order: 'desc',
|
|
62
|
+
});
|
|
63
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags');
|
|
64
|
+
expect(data).toHaveLength(3);
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
describe('with the after option', () => {
|
|
68
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
(0, test_utils_1.fetchOnce)(list_feature_flags_json_1.default);
|
|
70
|
+
const { data } = yield workos.featureFlags.listFeatureFlags({
|
|
71
|
+
after: 'flag_after_id',
|
|
72
|
+
});
|
|
73
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
74
|
+
after: 'flag_after_id',
|
|
75
|
+
order: 'desc',
|
|
76
|
+
});
|
|
77
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags');
|
|
78
|
+
expect(data).toHaveLength(3);
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
describe('with the limit option', () => {
|
|
82
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
(0, test_utils_1.fetchOnce)(list_feature_flags_json_1.default);
|
|
84
|
+
const { data } = yield workos.featureFlags.listFeatureFlags({
|
|
85
|
+
limit: 10,
|
|
86
|
+
});
|
|
87
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
88
|
+
limit: '10',
|
|
89
|
+
order: 'desc',
|
|
90
|
+
});
|
|
91
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags');
|
|
92
|
+
expect(data).toHaveLength(3);
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('getFeatureFlag', () => {
|
|
97
|
+
it('requests a feature flag by slug', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
(0, test_utils_1.fetchOnce)(get_feature_flag_json_1.default);
|
|
99
|
+
const subject = yield workos.featureFlags.getFeatureFlag('advanced-dashboard');
|
|
100
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard');
|
|
101
|
+
expect(subject).toEqual({
|
|
102
|
+
object: 'feature_flag',
|
|
103
|
+
id: 'flag_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
104
|
+
name: 'Advanced Dashboard',
|
|
105
|
+
slug: 'advanced-dashboard',
|
|
106
|
+
description: 'Enable advanced dashboard features',
|
|
107
|
+
tags: ['ui'],
|
|
108
|
+
enabled: true,
|
|
109
|
+
defaultValue: false,
|
|
110
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
111
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
112
|
+
});
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
describe('enableFeatureFlag', () => {
|
|
116
|
+
it('enables a feature flag by slug', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
(0, test_utils_1.fetchOnce)(enable_feature_flag_json_1.default);
|
|
118
|
+
const subject = yield workos.featureFlags.enableFeatureFlag('advanced-dashboard');
|
|
119
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard/enable');
|
|
120
|
+
expect((0, test_utils_1.fetchMethod)()).toBe('PUT');
|
|
121
|
+
expect(subject.enabled).toBe(true);
|
|
122
|
+
}));
|
|
123
|
+
});
|
|
124
|
+
describe('disableFeatureFlag', () => {
|
|
125
|
+
it('disables a feature flag by slug', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
(0, test_utils_1.fetchOnce)(disable_feature_flag_json_1.default);
|
|
127
|
+
const subject = yield workos.featureFlags.disableFeatureFlag('advanced-dashboard');
|
|
128
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard/disable');
|
|
129
|
+
expect((0, test_utils_1.fetchMethod)()).toBe('PUT');
|
|
130
|
+
expect(subject.enabled).toBe(false);
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
describe('addFlagTarget', () => {
|
|
134
|
+
it('adds a target to a feature flag', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
+
(0, test_utils_1.fetchOnce)({}, { status: 204 });
|
|
136
|
+
yield workos.featureFlags.addFlagTarget({
|
|
137
|
+
slug: 'advanced-dashboard',
|
|
138
|
+
targetId: 'user_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
139
|
+
});
|
|
140
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard/targets/user_01EHQMYV6MBK39QC5PZXHY59C5');
|
|
141
|
+
expect((0, test_utils_1.fetchMethod)()).toBe('POST');
|
|
142
|
+
}));
|
|
143
|
+
it('adds an organization target to a feature flag', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
(0, test_utils_1.fetchOnce)({}, { status: 204 });
|
|
145
|
+
yield workos.featureFlags.addFlagTarget({
|
|
146
|
+
slug: 'advanced-dashboard',
|
|
147
|
+
targetId: 'org_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
148
|
+
});
|
|
149
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard/targets/org_01EHQMYV6MBK39QC5PZXHY59C5');
|
|
150
|
+
expect((0, test_utils_1.fetchMethod)()).toBe('POST');
|
|
151
|
+
}));
|
|
152
|
+
});
|
|
153
|
+
describe('removeFlagTarget', () => {
|
|
154
|
+
it('removes a target from a feature flag', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
(0, test_utils_1.fetchOnce)({}, { status: 204 });
|
|
156
|
+
yield workos.featureFlags.removeFlagTarget({
|
|
157
|
+
slug: 'advanced-dashboard',
|
|
158
|
+
targetId: 'user_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
159
|
+
});
|
|
160
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard/targets/user_01EHQMYV6MBK39QC5PZXHY59C5');
|
|
161
|
+
expect((0, test_utils_1.fetchMethod)()).toBe('DELETE');
|
|
162
|
+
}));
|
|
163
|
+
it('removes an organization target from a feature flag', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
(0, test_utils_1.fetchOnce)({}, { status: 204 });
|
|
165
|
+
yield workos.featureFlags.removeFlagTarget({
|
|
166
|
+
slug: 'advanced-dashboard',
|
|
167
|
+
targetId: 'org_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
168
|
+
});
|
|
169
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/feature-flags/advanced-dashboard/targets/org_01EHQMYV6MBK39QC5PZXHY59C5');
|
|
170
|
+
expect((0, test_utils_1.fetchMethod)()).toBe('DELETE');
|
|
171
|
+
}));
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "feature_flag",
|
|
3
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C5",
|
|
4
|
+
"name": "Advanced Dashboard",
|
|
5
|
+
"slug": "advanced-dashboard",
|
|
6
|
+
"description": "Enable advanced dashboard features",
|
|
7
|
+
"tags": ["ui"],
|
|
8
|
+
"enabled": false,
|
|
9
|
+
"default_value": false,
|
|
10
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
11
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "feature_flag",
|
|
3
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C5",
|
|
4
|
+
"name": "Advanced Dashboard",
|
|
5
|
+
"slug": "advanced-dashboard",
|
|
6
|
+
"description": "Enable advanced dashboard features",
|
|
7
|
+
"tags": ["ui"],
|
|
8
|
+
"enabled": true,
|
|
9
|
+
"default_value": false,
|
|
10
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
11
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "feature_flag",
|
|
3
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C5",
|
|
4
|
+
"name": "Advanced Dashboard",
|
|
5
|
+
"slug": "advanced-dashboard",
|
|
6
|
+
"description": "Enable advanced dashboard features",
|
|
7
|
+
"tags": ["ui"],
|
|
8
|
+
"enabled": true,
|
|
9
|
+
"default_value": false,
|
|
10
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
11
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "list",
|
|
3
|
+
"data": [
|
|
4
|
+
{
|
|
5
|
+
"object": "feature_flag",
|
|
6
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C5",
|
|
7
|
+
"name": "Advanced Dashboard",
|
|
8
|
+
"slug": "advanced-dashboard",
|
|
9
|
+
"description": "Enable advanced dashboard features",
|
|
10
|
+
"tags": ["ui"],
|
|
11
|
+
"enabled": true,
|
|
12
|
+
"default_value": false,
|
|
13
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
14
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"object": "feature_flag",
|
|
18
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C6",
|
|
19
|
+
"name": "Beta Features",
|
|
20
|
+
"slug": "beta-features",
|
|
21
|
+
"description": "",
|
|
22
|
+
"tags": [],
|
|
23
|
+
"enabled": false,
|
|
24
|
+
"default_value": false,
|
|
25
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
26
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"object": "feature_flag",
|
|
30
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C7",
|
|
31
|
+
"name": "Premium Support",
|
|
32
|
+
"slug": "premium-support",
|
|
33
|
+
"description": "Access to premium support features",
|
|
34
|
+
"tags": ["dev-support"],
|
|
35
|
+
"enabled": false,
|
|
36
|
+
"default_value": true,
|
|
37
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
38
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"list_metadata": {
|
|
42
|
+
"before": null,
|
|
43
|
+
"after": "flag_01EHQMYV6MBK39QC5PZXHY59C7"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -3,7 +3,10 @@ export interface FeatureFlag {
|
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
5
|
slug: string;
|
|
6
|
-
description
|
|
6
|
+
description: string;
|
|
7
|
+
tags: string[];
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
defaultValue: boolean;
|
|
7
10
|
createdAt: string;
|
|
8
11
|
updatedAt: string;
|
|
9
12
|
}
|
|
@@ -12,7 +15,10 @@ export interface FeatureFlagResponse {
|
|
|
12
15
|
id: string;
|
|
13
16
|
name: string;
|
|
14
17
|
slug: string;
|
|
15
|
-
description
|
|
18
|
+
description: string;
|
|
19
|
+
tags: string[];
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
default_value: boolean;
|
|
16
22
|
created_at: string;
|
|
17
23
|
updated_at: string;
|
|
18
24
|
}
|
|
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./add-flag-target-options.interface"), exports);
|
|
17
18
|
__exportStar(require("./feature-flag.interface"), exports);
|
|
19
|
+
__exportStar(require("./list-feature-flags-options.interface"), exports);
|
|
20
|
+
__exportStar(require("./remove-flag-target-options.interface"), exports);
|
|
@@ -7,6 +7,9 @@ const deserializeFeatureFlag = (featureFlag) => ({
|
|
|
7
7
|
name: featureFlag.name,
|
|
8
8
|
slug: featureFlag.slug,
|
|
9
9
|
description: featureFlag.description,
|
|
10
|
+
tags: featureFlag.tags,
|
|
11
|
+
enabled: featureFlag.enabled,
|
|
12
|
+
defaultValue: featureFlag.default_value,
|
|
10
13
|
createdAt: featureFlag.created_at,
|
|
11
14
|
updatedAt: featureFlag.updated_at,
|
|
12
15
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './feature-flag.serializer';
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
__exportStar(require("./feature-flag.serializer"), exports);
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
"name": "Advanced Dashboard",
|
|
8
8
|
"slug": "advanced-dashboard",
|
|
9
9
|
"description": "Enable advanced dashboard features",
|
|
10
|
+
"tags": ["ui"],
|
|
11
|
+
"enabled": true,
|
|
12
|
+
"default_value": false,
|
|
10
13
|
"created_at": "2024-01-01T00:00:00.000Z",
|
|
11
14
|
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
12
15
|
},
|
|
@@ -15,7 +18,10 @@
|
|
|
15
18
|
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C6",
|
|
16
19
|
"name": "Beta Features",
|
|
17
20
|
"slug": "beta-features",
|
|
18
|
-
"description":
|
|
21
|
+
"description": "",
|
|
22
|
+
"tags": [],
|
|
23
|
+
"enabled": false,
|
|
24
|
+
"default_value": false,
|
|
19
25
|
"created_at": "2024-01-01T00:00:00.000Z",
|
|
20
26
|
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
21
27
|
},
|
|
@@ -25,6 +31,9 @@
|
|
|
25
31
|
"name": "Premium Support",
|
|
26
32
|
"slug": "premium-support",
|
|
27
33
|
"description": "Access to premium support features",
|
|
34
|
+
"tags": ["dev-support"],
|
|
35
|
+
"enabled": false,
|
|
36
|
+
"default_value": true,
|
|
28
37
|
"created_at": "2024-01-01T00:00:00.000Z",
|
|
29
38
|
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
30
39
|
}
|
|
@@ -25,7 +25,7 @@ const pagination_1 = require("../common/utils/pagination");
|
|
|
25
25
|
const serializers_1 = require("./serializers");
|
|
26
26
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
27
27
|
const role_serializer_1 = require("../roles/serializers/role.serializer");
|
|
28
|
-
const
|
|
28
|
+
const serializers_2 = require("../feature-flags/serializers");
|
|
29
29
|
class Organizations {
|
|
30
30
|
constructor(workos) {
|
|
31
31
|
this.workos = workos;
|
|
@@ -78,7 +78,7 @@ class Organizations {
|
|
|
78
78
|
listOrganizationFeatureFlags(options) {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
const { organizationId } = options, paginationOptions = __rest(options, ["organizationId"]);
|
|
81
|
-
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/organizations/${organizationId}/feature-flags`,
|
|
81
|
+
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/organizations/${organizationId}/feature-flags`, serializers_2.deserializeFeatureFlag, paginationOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/organizations/${organizationId}/feature-flags`, serializers_2.deserializeFeatureFlag, params), paginationOptions);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -373,6 +373,9 @@ describe('Organizations', () => {
|
|
|
373
373
|
name: 'Advanced Dashboard',
|
|
374
374
|
slug: 'advanced-dashboard',
|
|
375
375
|
description: 'Enable advanced dashboard features',
|
|
376
|
+
tags: ['ui'],
|
|
377
|
+
enabled: true,
|
|
378
|
+
defaultValue: false,
|
|
376
379
|
createdAt: '2024-01-01T00:00:00.000Z',
|
|
377
380
|
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
378
381
|
},
|
|
@@ -381,7 +384,10 @@ describe('Organizations', () => {
|
|
|
381
384
|
id: 'flag_01EHQMYV6MBK39QC5PZXHY59C6',
|
|
382
385
|
name: 'Beta Features',
|
|
383
386
|
slug: 'beta-features',
|
|
384
|
-
description:
|
|
387
|
+
description: '',
|
|
388
|
+
tags: [],
|
|
389
|
+
enabled: false,
|
|
390
|
+
defaultValue: false,
|
|
385
391
|
createdAt: '2024-01-01T00:00:00.000Z',
|
|
386
392
|
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
387
393
|
},
|
|
@@ -391,6 +397,9 @@ describe('Organizations', () => {
|
|
|
391
397
|
name: 'Premium Support',
|
|
392
398
|
slug: 'premium-support',
|
|
393
399
|
description: 'Access to premium support features',
|
|
400
|
+
tags: ['dev-support'],
|
|
401
|
+
enabled: false,
|
|
402
|
+
defaultValue: true,
|
|
394
403
|
createdAt: '2024-01-01T00:00:00.000Z',
|
|
395
404
|
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
396
405
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AccessToken {
|
|
2
|
+
object: 'access_token';
|
|
3
|
+
accessToken: string;
|
|
4
|
+
expiresAt: Date | null;
|
|
5
|
+
scopes: string[];
|
|
6
|
+
missingScopes: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface SerializedAccessToken {
|
|
9
|
+
object: 'access_token';
|
|
10
|
+
access_token: string;
|
|
11
|
+
expires_at: string | null;
|
|
12
|
+
scopes: string[];
|
|
13
|
+
missing_scopes: string[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AccessToken, SerializedAccessToken } from './access-token.interface';
|
|
2
|
+
export interface GetAccessTokenOptions {
|
|
3
|
+
userId: string;
|
|
4
|
+
organizationId?: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface SerializedGetAccessTokenOptions {
|
|
7
|
+
user_id: string;
|
|
8
|
+
organization_id?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface GetAccessTokenSuccessResponse {
|
|
11
|
+
active: true;
|
|
12
|
+
accessToken: AccessToken;
|
|
13
|
+
}
|
|
14
|
+
export interface GetAccessTokenFailureResponse {
|
|
15
|
+
active: false;
|
|
16
|
+
error: 'not_installed' | 'needs_reauthorization';
|
|
17
|
+
}
|
|
18
|
+
export type GetAccessTokenResponse = GetAccessTokenSuccessResponse | GetAccessTokenFailureResponse;
|
|
19
|
+
export interface SerializedGetAccessTokenSuccessResponse {
|
|
20
|
+
active: true;
|
|
21
|
+
access_token: SerializedAccessToken;
|
|
22
|
+
}
|
|
23
|
+
export interface SerializedGetAccessTokenFailureResponse {
|
|
24
|
+
active: false;
|
|
25
|
+
error: 'not_installed' | 'needs_reauthorization';
|
|
26
|
+
}
|
|
27
|
+
export type SerializedGetAccessTokenResponse = SerializedGetAccessTokenSuccessResponse | SerializedGetAccessTokenFailureResponse;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkOS } from '../workos';
|
|
2
|
+
import { GetAccessTokenOptions, GetAccessTokenResponse } from './interfaces/get-access-token.interface';
|
|
3
|
+
export declare class Pipes {
|
|
4
|
+
private readonly workos;
|
|
5
|
+
constructor(workos: WorkOS);
|
|
6
|
+
getAccessToken({ provider, ...options }: GetAccessTokenOptions & {
|
|
7
|
+
provider: string;
|
|
8
|
+
}): Promise<GetAccessTokenResponse>;
|
|
9
|
+
}
|