@flowcore/cli-plugin-iam 1.0.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.
@@ -0,0 +1,81 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /*
4
+ * ---------------------------------------------------------------
5
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
+ * ## ##
7
+ * ## AUTHOR: acacode ##
8
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
+ * ---------------------------------------------------------------
10
+ */
11
+ import { ContentType, HttpClient } from "./http-client.js";
12
+ export class Transformers extends HttpClient {
13
+ /**
14
+ * No description
15
+ *
16
+ * @tags transformers
17
+ * @name PostTransformersIam0
18
+ * @request POST:/transformers/iam.0
19
+ * @secure
20
+ */
21
+ postTransformersIam0 = (data, params = {}) => this.request({
22
+ path: `/transformers/iam.0`,
23
+ method: "POST",
24
+ body: data,
25
+ secure: true,
26
+ type: ContentType.Json,
27
+ format: "json",
28
+ ...params,
29
+ });
30
+ /**
31
+ * No description
32
+ *
33
+ * @tags transformers
34
+ * @name PostTransformersOrganization0
35
+ * @request POST:/transformers/organization.0
36
+ * @secure
37
+ */
38
+ postTransformersOrganization0 = (data, params = {}) => this.request({
39
+ path: `/transformers/organization.0`,
40
+ method: "POST",
41
+ body: data,
42
+ secure: true,
43
+ type: ContentType.Json,
44
+ format: "json",
45
+ ...params,
46
+ });
47
+ /**
48
+ * No description
49
+ *
50
+ * @tags transformers
51
+ * @name PostTransformersUser0
52
+ * @request POST:/transformers/user.0
53
+ * @secure
54
+ */
55
+ postTransformersUser0 = (data, params = {}) => this.request({
56
+ path: `/transformers/user.0`,
57
+ method: "POST",
58
+ body: data,
59
+ secure: true,
60
+ type: ContentType.Json,
61
+ format: "json",
62
+ ...params,
63
+ });
64
+ /**
65
+ * No description
66
+ *
67
+ * @tags transformers
68
+ * @name PostTransformersSecurity0
69
+ * @request POST:/transformers/security.0
70
+ * @secure
71
+ */
72
+ postTransformersSecurity0 = (data, params = {}) => this.request({
73
+ path: `/transformers/security.0`,
74
+ method: "POST",
75
+ body: data,
76
+ secure: true,
77
+ type: ContentType.Json,
78
+ format: "json",
79
+ ...params,
80
+ });
81
+ }
@@ -0,0 +1,59 @@
1
+ export type QueryParamsType = Record<string | number, any>;
2
+ export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
3
+ export interface FullRequestParams extends Omit<RequestInit, "body"> {
4
+ /** set parameter to `true` for call `securityWorker` for this request */
5
+ secure?: boolean;
6
+ /** request path */
7
+ path: string;
8
+ /** content type of request body */
9
+ type?: ContentType;
10
+ /** query params */
11
+ query?: QueryParamsType;
12
+ /** format of response (i.e. response.json() -> format: "json") */
13
+ format?: ResponseFormat;
14
+ /** request body */
15
+ body?: unknown;
16
+ /** base url */
17
+ baseUrl?: string;
18
+ /** request cancellation token */
19
+ cancelToken?: CancelToken;
20
+ }
21
+ export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
22
+ export interface ApiConfig<SecurityDataType = unknown> {
23
+ baseUrl?: string;
24
+ baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
25
+ securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
26
+ customFetch?: typeof fetch;
27
+ }
28
+ export interface HttpResponse<D, E = unknown> extends Response {
29
+ data: D;
30
+ error: E;
31
+ }
32
+ type CancelToken = symbol | string | number;
33
+ export declare enum ContentType {
34
+ Json = "application/json",
35
+ FormData = "multipart/form-data",
36
+ UrlEncoded = "application/x-www-form-urlencoded",
37
+ Text = "text/plain"
38
+ }
39
+ export declare class HttpClient<SecurityDataType = unknown> {
40
+ baseUrl: string;
41
+ private securityData;
42
+ private securityWorker?;
43
+ private abortControllers;
44
+ private customFetch;
45
+ private baseApiParams;
46
+ constructor(apiConfig?: ApiConfig<SecurityDataType>);
47
+ setSecurityData: (data: SecurityDataType | null) => void;
48
+ protected encodeQueryParam(key: string, value: any): string;
49
+ protected addQueryParam(query: QueryParamsType, key: string): string;
50
+ protected addArrayQueryParam(query: QueryParamsType, key: string): any;
51
+ protected toQueryString(rawQuery?: QueryParamsType): string;
52
+ protected addQueryParams(rawQuery?: QueryParamsType): string;
53
+ private contentFormatters;
54
+ protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
55
+ protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
56
+ abortRequest: (cancelToken: CancelToken) => void;
57
+ request: <T = any, E = any>({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }: FullRequestParams) => Promise<HttpResponse<T, E>>;
58
+ }
59
+ export {};
@@ -0,0 +1,160 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /*
4
+ * ---------------------------------------------------------------
5
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
+ * ## ##
7
+ * ## AUTHOR: acacode ##
8
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
+ * ---------------------------------------------------------------
10
+ */
11
+ export var ContentType;
12
+ (function (ContentType) {
13
+ ContentType["Json"] = "application/json";
14
+ ContentType["FormData"] = "multipart/form-data";
15
+ ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
16
+ ContentType["Text"] = "text/plain";
17
+ })(ContentType || (ContentType = {}));
18
+ export class HttpClient {
19
+ baseUrl = "https://iam.api.flowcore.io";
20
+ securityData = null;
21
+ securityWorker;
22
+ abortControllers = new Map();
23
+ customFetch = (...fetchParams) => fetch(...fetchParams);
24
+ baseApiParams = {
25
+ credentials: "same-origin",
26
+ headers: {},
27
+ redirect: "follow",
28
+ referrerPolicy: "no-referrer",
29
+ };
30
+ constructor(apiConfig = {}) {
31
+ Object.assign(this, apiConfig);
32
+ }
33
+ setSecurityData = (data) => {
34
+ this.securityData = data;
35
+ };
36
+ encodeQueryParam(key, value) {
37
+ const encodedKey = encodeURIComponent(key);
38
+ return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
39
+ }
40
+ addQueryParam(query, key) {
41
+ return this.encodeQueryParam(key, query[key]);
42
+ }
43
+ addArrayQueryParam(query, key) {
44
+ const value = query[key];
45
+ return value.map((v) => this.encodeQueryParam(key, v)).join("&");
46
+ }
47
+ toQueryString(rawQuery) {
48
+ const query = rawQuery || {};
49
+ const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
50
+ return keys
51
+ .map((key) => Array.isArray(query[key])
52
+ ? this.addArrayQueryParam(query, key)
53
+ : this.addQueryParam(query, key))
54
+ .join("&");
55
+ }
56
+ addQueryParams(rawQuery) {
57
+ const queryString = this.toQueryString(rawQuery);
58
+ return queryString ? `?${queryString}` : "";
59
+ }
60
+ contentFormatters = {
61
+ [ContentType.Json]: (input) => input !== null && (typeof input === "object" || typeof input === "string")
62
+ ? JSON.stringify(input)
63
+ : input,
64
+ [ContentType.Text]: (input) => input !== null && typeof input !== "string"
65
+ ? JSON.stringify(input)
66
+ : input,
67
+ [ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => {
68
+ const property = input[key];
69
+ formData.append(key, property instanceof Blob
70
+ ? property
71
+ : typeof property === "object" && property !== null
72
+ ? JSON.stringify(property)
73
+ : `${property}`);
74
+ return formData;
75
+ }, new FormData()),
76
+ [ContentType.UrlEncoded]: (input) => this.toQueryString(input),
77
+ };
78
+ mergeRequestParams(params1, params2) {
79
+ return {
80
+ ...this.baseApiParams,
81
+ ...params1,
82
+ ...(params2 || {}),
83
+ headers: {
84
+ ...(this.baseApiParams.headers || {}),
85
+ ...(params1.headers || {}),
86
+ ...((params2 && params2.headers) || {}),
87
+ },
88
+ };
89
+ }
90
+ createAbortSignal = (cancelToken) => {
91
+ if (this.abortControllers.has(cancelToken)) {
92
+ const abortController = this.abortControllers.get(cancelToken);
93
+ if (abortController) {
94
+ return abortController.signal;
95
+ }
96
+ return void 0;
97
+ }
98
+ const abortController = new AbortController();
99
+ this.abortControllers.set(cancelToken, abortController);
100
+ return abortController.signal;
101
+ };
102
+ abortRequest = (cancelToken) => {
103
+ const abortController = this.abortControllers.get(cancelToken);
104
+ if (abortController) {
105
+ abortController.abort();
106
+ this.abortControllers.delete(cancelToken);
107
+ }
108
+ };
109
+ request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => {
110
+ const secureParams = ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) &&
111
+ this.securityWorker &&
112
+ (await this.securityWorker(this.securityData))) ||
113
+ {};
114
+ const requestParams = this.mergeRequestParams(params, secureParams);
115
+ const queryString = query && this.toQueryString(query);
116
+ const payloadFormatter = this.contentFormatters[type || ContentType.Json];
117
+ const responseFormat = format || requestParams.format;
118
+ return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, {
119
+ ...requestParams,
120
+ headers: {
121
+ ...(requestParams.headers || {}),
122
+ ...(type && type !== ContentType.FormData
123
+ ? { "Content-Type": type }
124
+ : {}),
125
+ },
126
+ signal: (cancelToken
127
+ ? this.createAbortSignal(cancelToken)
128
+ : requestParams.signal) || null,
129
+ body: typeof body === "undefined" || body === null
130
+ ? null
131
+ : payloadFormatter(body),
132
+ }).then(async (response) => {
133
+ const r = response.clone();
134
+ r.data = null;
135
+ r.error = null;
136
+ const data = !responseFormat
137
+ ? r
138
+ : await response[responseFormat]()
139
+ .then((data) => {
140
+ if (r.ok) {
141
+ r.data = data;
142
+ }
143
+ else {
144
+ r.error = data;
145
+ }
146
+ return r;
147
+ })
148
+ .catch((e) => {
149
+ r.error = e;
150
+ return r;
151
+ });
152
+ if (cancelToken) {
153
+ this.abortControllers.delete(cancelToken);
154
+ }
155
+ if (!response.ok)
156
+ throw data;
157
+ return data;
158
+ });
159
+ };
160
+ }
@@ -0,0 +1,2 @@
1
+ import merge from 'deepmerge';
2
+ export declare const combineMerge: (target: unknown[], source: unknown[], options: merge.ArrayMergeOptions) => unknown[];
@@ -0,0 +1,16 @@
1
+ import merge from 'deepmerge';
2
+ export const combineMerge = (target, source, options) => {
3
+ const destination = [...target];
4
+ for (const [index, item] of source.entries()) {
5
+ if (destination[index] === undefined) {
6
+ destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
7
+ }
8
+ else if (options.isMergeableObject(item)) {
9
+ destination[index] = merge(target[index], item, options);
10
+ }
11
+ else if (!target.includes(item)) {
12
+ destination.push(item);
13
+ }
14
+ }
15
+ return destination;
16
+ };
@@ -0,0 +1,6 @@
1
+ export interface Parser<T> {
2
+ parse(raw: unknown): T;
3
+ }
4
+ export declare const FetchManifestUtil: {
5
+ fetchManifest<T>(files: string[], parser: Parser<T>): Promise<T>;
6
+ };
@@ -0,0 +1,56 @@
1
+ import { ux } from "@oclif/core";
2
+ import merge from "deepmerge";
3
+ import { load } from "js-yaml";
4
+ import fs from "node:fs";
5
+ import { combineMerge } from "./combine-merge.util.js";
6
+ import { readPipe } from "./read-pipe.util.js";
7
+ export const FetchManifestUtil = {
8
+ async fetchManifest(files, parser) {
9
+ const contents = [];
10
+ for (const file of files) {
11
+ if (file === "-") {
12
+ // eslint-disable-next-line no-await-in-loop
13
+ contents.push(await readPipe() || "");
14
+ }
15
+ else if (fs.existsSync(file)) {
16
+ contents.push(fs.readFileSync(file, "utf8"));
17
+ }
18
+ else {
19
+ ux.error(`File not found: ${file}`);
20
+ }
21
+ }
22
+ if (contents.length === 0) {
23
+ ux.error("No file content found");
24
+ }
25
+ let rawYaml;
26
+ for (const content of contents) {
27
+ try {
28
+ const parsed = load(content);
29
+ if (!parsed) {
30
+ continue;
31
+ }
32
+ if (!rawYaml) {
33
+ rawYaml = parsed;
34
+ continue;
35
+ }
36
+ rawYaml = merge(rawYaml, parsed, {
37
+ arrayMerge: combineMerge,
38
+ });
39
+ }
40
+ catch (error) {
41
+ ux.error(`Invalid YAML: ${error}`);
42
+ }
43
+ }
44
+ let yaml;
45
+ try {
46
+ yaml = parser.parse(rawYaml);
47
+ }
48
+ catch (error) {
49
+ ux.error(`Invalid YAML: ${error}`);
50
+ }
51
+ if (!yaml) {
52
+ ux.error("Invalid YAML");
53
+ }
54
+ return yaml;
55
+ },
56
+ };
@@ -0,0 +1,14 @@
1
+ export type FetchMyOrganizationsQueryResponse = {
2
+ me: {
3
+ id: string;
4
+ organizations: {
5
+ linkType: string;
6
+ organization: {
7
+ displayName: string;
8
+ id: string;
9
+ org: string;
10
+ };
11
+ }[];
12
+ };
13
+ };
14
+ export declare const FETCH_MY_ORGANIZATIONS_GQL_QUERY: string;
@@ -0,0 +1,16 @@
1
+ import { gql } from "graphql-request";
2
+ export const FETCH_MY_ORGANIZATIONS_GQL_QUERY = gql `
3
+ query FLOWCORE_CLI_FETCH_MY_ORGANIZATIONS {
4
+ me {
5
+ id
6
+ organizations {
7
+ organization {
8
+ id
9
+ displayName
10
+ org
11
+ }
12
+ linkType
13
+ }
14
+ }
15
+ }
16
+ `;
@@ -0,0 +1 @@
1
+ export declare const readPipe: () => Promise<string | undefined>;
@@ -0,0 +1,14 @@
1
+ export const readPipe = () => new Promise(resolve => {
2
+ const stdin = process.openStdin();
3
+ stdin.setEncoding("utf8");
4
+ let data = '';
5
+ stdin.on('data', chunk => {
6
+ data += chunk;
7
+ });
8
+ stdin.on('end', () => {
9
+ resolve(data);
10
+ });
11
+ if (stdin.isTTY) {
12
+ resolve('');
13
+ }
14
+ });
@@ -0,0 +1,127 @@
1
+ {
2
+ "commands": {
3
+ "get:policy": {
4
+ "aliases": [],
5
+ "args": {
6
+ "NAME": {
7
+ "description": "name",
8
+ "name": "NAME",
9
+ "required": false
10
+ }
11
+ },
12
+ "description": "Get a policy",
13
+ "examples": [],
14
+ "flags": {
15
+ "profile": {
16
+ "description": "Specify the configuration profile to use",
17
+ "name": "profile",
18
+ "hasDynamicHelp": false,
19
+ "multiple": false,
20
+ "type": "option"
21
+ },
22
+ "json": {
23
+ "char": "j",
24
+ "description": "json output",
25
+ "name": "json",
26
+ "required": false,
27
+ "allowNo": false,
28
+ "type": "boolean"
29
+ },
30
+ "tenant": {
31
+ "char": "t",
32
+ "description": "tenant",
33
+ "name": "tenant",
34
+ "required": false,
35
+ "hasDynamicHelp": false,
36
+ "multiple": false,
37
+ "type": "option"
38
+ },
39
+ "wide": {
40
+ "char": "w",
41
+ "description": "wide output",
42
+ "name": "wide",
43
+ "required": false,
44
+ "allowNo": false,
45
+ "type": "boolean"
46
+ }
47
+ },
48
+ "hasDynamicHelp": false,
49
+ "hiddenAliases": [],
50
+ "id": "get:policy",
51
+ "pluginAlias": "@flowcore/cli-plugin-iam",
52
+ "pluginName": "@flowcore/cli-plugin-iam",
53
+ "pluginType": "core",
54
+ "strict": true,
55
+ "enableJsonFlag": false,
56
+ "isESM": true,
57
+ "relativePath": [
58
+ "dist",
59
+ "commands",
60
+ "get",
61
+ "policy.js"
62
+ ]
63
+ },
64
+ "get:role": {
65
+ "aliases": [],
66
+ "args": {
67
+ "NAME": {
68
+ "description": "name",
69
+ "name": "NAME",
70
+ "required": false
71
+ }
72
+ },
73
+ "description": "Get a role",
74
+ "examples": [],
75
+ "flags": {
76
+ "profile": {
77
+ "description": "Specify the configuration profile to use",
78
+ "name": "profile",
79
+ "hasDynamicHelp": false,
80
+ "multiple": false,
81
+ "type": "option"
82
+ },
83
+ "json": {
84
+ "char": "j",
85
+ "description": "json output",
86
+ "name": "json",
87
+ "required": false,
88
+ "allowNo": false,
89
+ "type": "boolean"
90
+ },
91
+ "tenant": {
92
+ "char": "t",
93
+ "description": "tenant",
94
+ "name": "tenant",
95
+ "required": false,
96
+ "hasDynamicHelp": false,
97
+ "multiple": false,
98
+ "type": "option"
99
+ },
100
+ "wide": {
101
+ "char": "w",
102
+ "description": "wide output",
103
+ "name": "wide",
104
+ "required": false,
105
+ "allowNo": false,
106
+ "type": "boolean"
107
+ }
108
+ },
109
+ "hasDynamicHelp": false,
110
+ "hiddenAliases": [],
111
+ "id": "get:role",
112
+ "pluginAlias": "@flowcore/cli-plugin-iam",
113
+ "pluginName": "@flowcore/cli-plugin-iam",
114
+ "pluginType": "core",
115
+ "strict": true,
116
+ "enableJsonFlag": false,
117
+ "isESM": true,
118
+ "relativePath": [
119
+ "dist",
120
+ "commands",
121
+ "get",
122
+ "role.js"
123
+ ]
124
+ }
125
+ },
126
+ "version": "1.0.0"
127
+ }
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "author": "flowcore-platform",
3
+ "bin": {
4
+ "scenario": "./bin/run.js"
5
+ },
6
+ "dependencies": {
7
+ "@flowcore/cli-plugin-config": "^2.2.1",
8
+ "@flowcore/cli-plugin-core": "^4.0.3",
9
+ "@oclif/core": "^4.0.21",
10
+ "@oclif/plugin-help": "^6",
11
+ "@oclif/plugin-plugins": "^5.4.7",
12
+ "dayjs": "^1.11.10",
13
+ "deepmerge": "^4.3.1",
14
+ "enquirer": "^2.4.1",
15
+ "graphql": "^16.8.1",
16
+ "graphql-request": "^6.1.0",
17
+ "js-yaml": "^4.1.0",
18
+ "lodash": "^4.17.21",
19
+ "radash": "^12.1.0",
20
+ "uuid": "^9.0.1",
21
+ "zod": "^3.22.4"
22
+ },
23
+ "description": "Flowcore CLI plugin for managing the IAM of the Flowcore Platform",
24
+ "devDependencies": {
25
+ "@oclif/prettier-config": "^0.2.1",
26
+ "@oclif/test": "^4.0.9",
27
+ "@types/chai": "^4",
28
+ "@types/deepmerge": "^2.2.0",
29
+ "@types/js-yaml": "^4.0.9",
30
+ "@types/lodash": "^4.14.202",
31
+ "@types/mocha": "^10",
32
+ "@types/node": "^18",
33
+ "@types/uuid": "^9.0.8",
34
+ "chai": "^4",
35
+ "eslint": "^8",
36
+ "eslint-config-oclif": "^5",
37
+ "eslint-config-oclif-typescript": "^3",
38
+ "eslint-config-prettier": "^9.1.0",
39
+ "mocha": "^10",
40
+ "oclif": "^4.4.12",
41
+ "shx": "^0.3.4",
42
+ "ts-node": "^10.9.2",
43
+ "typescript": "5^"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "files": [
49
+ "/bin",
50
+ "/dist",
51
+ "/oclif.manifest.json"
52
+ ],
53
+ "homepage": "https://github.com/flowcore-io/cli-plugin-iam",
54
+ "license": "MIT",
55
+ "main": "",
56
+ "name": "@flowcore/cli-plugin-iam",
57
+ "oclif": {
58
+ "bin": "iam",
59
+ "dirname": "iam",
60
+ "commands": "./dist/commands",
61
+ "devPlugins": [
62
+ "@oclif/plugin-help",
63
+ "@oclif/plugin-plugins",
64
+ "@flowcore/cli-plugin-config"
65
+ ],
66
+ "topicSeparator": " ",
67
+ "topics": {
68
+ "iam": {
69
+ "description": "Flowcore CLI plugin for managing the IAM of the Flowcore Platform"
70
+ }
71
+ }
72
+ },
73
+ "repository": "flowcore-io/cli-plugin-iam",
74
+ "scripts": {
75
+ "build": "shx rm -rf dist && tsc -b",
76
+ "lint": "eslint . --ext .ts",
77
+ "postpack": "shx rm -f oclif.manifest.json",
78
+ "posttest": "yarn run lint",
79
+ "prepack": "yarn run build && oclif manifest && oclif readme",
80
+ "prepare": "yarn run build",
81
+ "test": "mocha --forbid-only \"test/**/*.test.ts\"",
82
+ "version": "oclif readme && git add README.md",
83
+ "update-schema": "rover graph introspect https://graph.api.flowcore.io/graphql -o schema.gql"
84
+ },
85
+ "version": "1.0.0",
86
+ "bugs": "https://github.com/flowcore-io/cli-plugin-iam/issues",
87
+ "keywords": [
88
+ "oclif"
89
+ ],
90
+ "types": "dist/index.d.ts",
91
+ "exports": "./dist/index.js",
92
+ "type": "module"
93
+ }