@cinerino/sdk 11.0.0-alpha.3 → 11.0.0-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "11.0.0-alpha.3",
3
+ "version": "11.0.0-alpha.4",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -1,34 +0,0 @@
1
- // tslint:disable:no-implicit-dependencies no-console no-magic-numbers
2
- import * as client from '../../../lib/';
3
-
4
- const project = { id: 'cinerino' };
5
-
6
- async function main() {
7
- const authClient = await client.auth.ClientCredentials.createInstance({
8
- domain: <string>process.env.CHEVRE_AUTHORIZE_SERVER_DOMAIN,
9
- clientId: <string>process.env.CHEVRE_CLIENT_ID,
10
- clientSecret: <string>process.env.CHEVRE_CLIENT_SECRET,
11
- scopes: [],
12
- state: ''
13
- });
14
- const permitService = await (await client.loadChevreAsset({
15
- endpoint: <string>process.env.CHEVRE_ENDPOINT,
16
- auth: authClient
17
- })).createPermitInstance({
18
- project,
19
- seller: { id: '' }
20
- });
21
-
22
- // tslint:disable-next-line:prefer-array-literal
23
- const result = await permitService.publishIdentifier([...Array(100)].map(() => {
24
- return { project };
25
- }));
26
- console.log(result);
27
- console.log(result.length, 'identifiers published');
28
- }
29
-
30
- main()
31
- .then(() => {
32
- console.log('main processed.');
33
- })
34
- .catch(console.error);
@@ -1,57 +0,0 @@
1
- // tslint:disable:no-console
2
- import { factory, loadCloudAdmin } from '../../../lib/index';
3
- import * as auth from '../auth/authAsAdmin';
4
-
5
- const project = { id: String(process.env.PROJECT_ID) };
6
- async function main() {
7
- const authClient = await auth.login();
8
- await authClient.refreshAccessToken();
9
- const loginTicket = authClient.verifyIdToken({});
10
- console.log('username is', loginTicket.getUsername());
11
-
12
- const memberService = await (await loadCloudAdmin({
13
- endpoint: <string>process.env.API_ADMIN_ENDPOINT,
14
- auth: authClient
15
- })).createMemberInstance({
16
- project: { id: project.id },
17
- seller: { id: '59d20831e53ebc2b4e774466' }
18
- });
19
- const authorizationService = await (await loadCloudAdmin({
20
- endpoint: <string>process.env.API_ADMIN_ENDPOINT,
21
- auth: authClient
22
- })).createAuthorizationInstance({
23
- project: { id: project.id },
24
- seller: { id: '59d20831e53ebc2b4e774466' } // 販売者を指定(承認するロールの範囲が販売者リソースになる)
25
- });
26
-
27
- const applications = await memberService.searchSoftwareApplications({
28
- limit: 10,
29
- page: 1
30
- });
31
- console.log(applications);
32
- console.log(applications.length, 'applications found');
33
-
34
- if (applications.length > 0) {
35
- const result = await authorizationService.create([{
36
- object: {
37
- typeOf: factory.role.RoleType.OrganizationRole,
38
- member: {
39
- hasRole: [
40
- { roleName: 'sellers.inventoryManager' }
41
- ]
42
- }
43
- },
44
- expiresInSeconds: 60,
45
- audience: { id: applications[0].id }
46
- }]);
47
- console.log(result);
48
- } else {
49
- console.log('no software applications');
50
- }
51
- }
52
-
53
- main()
54
- .then(() => {
55
- console.log('success!');
56
- })
57
- .catch(console.error);
@@ -1,63 +0,0 @@
1
-
2
- // tslint:disable:no-console
3
- async function getToken() {
4
- try {
5
- const response = await fetch(
6
- `https://${process.env.ST_AUTHORIZE_SERVER_DOMAIN}/oauth2/token`,
7
- {
8
- method: 'POST',
9
- headers: {
10
- 'Content-Type': 'application/x-www-form-urlencoded'
11
- },
12
- body: new URLSearchParams({
13
- grant_type: 'client_credentials',
14
- client_id: String(process.env.ST_CLIENT_ID),
15
- client_secret: String(process.env.ST_CLIENT_SECRET)
16
- }).toString()
17
- });
18
-
19
- if (!response.ok) {
20
- console.log(await response.json());
21
- throw new Error('Network response was not ok');
22
- }
23
-
24
- const data = await response.json();
25
- console.log(data);
26
-
27
- return data;
28
- } catch (error) {
29
- console.error('Error fetching token:', error);
30
- }
31
- }
32
- async function fetchData(params: {
33
- access_token: string;
34
- // scope: string;
35
- // expires_in: number;
36
- // token_type: 'Bearer';
37
- }) {
38
- try {
39
- const { access_token } = params;
40
- const response = await fetch(
41
- `${process.env.ST_API_ENDPOINT}/events/ScreeningEvent?limit=1`,
42
- {
43
- method: 'GET',
44
- headers: {
45
- authorization: `Bearer ${access_token}`
46
- }
47
- });
48
- if (!response.ok) {
49
- throw new Error(await response.text());
50
- }
51
- const data = await response.json();
52
- console.log(data);
53
- } catch (error) {
54
- console.error('Error fetching data:', error);
55
- }
56
- }
57
- async function main() {
58
- const token = await getToken();
59
- await fetchData(token);
60
- }
61
-
62
- main()
63
- .catch(console.error);
@@ -1,16 +0,0 @@
1
- import { ICreatedAuthorization, ICreateParams } from '../../chevreAdmin/authorization';
2
- import { Service } from '../../service';
3
- /**
4
- * 承認サービス
5
- */
6
- export declare class AuthorizationService extends Service {
7
- /**
8
- * 承認作成(イベント作成チケット発行)
9
- */
10
- create(
11
- /**
12
- * 承認作成パラメータ
13
- * 最大長: 1
14
- */
15
- params: ICreateParams[]): Promise<ICreatedAuthorization[]>;
16
- }
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.AuthorizationService = void 0;
55
- var index_1 = require("../../index");
56
- var service_1 = require("../../service");
57
- /**
58
- * 承認サービス
59
- */
60
- var AuthorizationService = /** @class */ (function (_super) {
61
- __extends(AuthorizationService, _super);
62
- function AuthorizationService() {
63
- return _super !== null && _super.apply(this, arguments) || this;
64
- }
65
- /**
66
- * 承認作成(イベント作成チケット発行)
67
- */
68
- AuthorizationService.prototype.create = function (
69
- /**
70
- * 承認作成パラメータ
71
- * 最大長: 1
72
- */
73
- params) {
74
- return __awaiter(this, void 0, void 0, function () {
75
- var _a, auth, endpoint, project, seller, chevreAdmin;
76
- return __generator(this, function (_b) {
77
- switch (_b.label) {
78
- case 0:
79
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller;
80
- return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
81
- case 1:
82
- chevreAdmin = _b.sent();
83
- return [4 /*yield*/, chevreAdmin.createAuthorizationInstance({
84
- project: project,
85
- seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
86
- })];
87
- case 2: return [2 /*return*/, (_b.sent()).create(params)];
88
- }
89
- });
90
- });
91
- };
92
- return AuthorizationService;
93
- }(service_1.Service));
94
- exports.AuthorizationService = AuthorizationService;
@@ -1,17 +0,0 @@
1
- import { IMember } from '../../chevreAdmin/member';
2
- import { Service } from '../../service';
3
- /**
4
- * メンバーサービス
5
- */
6
- export declare class MemberService extends Service {
7
- /**
8
- * ソフトウェア検索
9
- */
10
- searchSoftwareApplications(params: {
11
- /**
12
- * max: 20
13
- */
14
- limit?: number;
15
- page?: number;
16
- }): Promise<IMember[]>;
17
- }
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.MemberService = void 0;
55
- var index_1 = require("../../index");
56
- var service_1 = require("../../service");
57
- /**
58
- * メンバーサービス
59
- */
60
- var MemberService = /** @class */ (function (_super) {
61
- __extends(MemberService, _super);
62
- function MemberService() {
63
- return _super !== null && _super.apply(this, arguments) || this;
64
- }
65
- /**
66
- * ソフトウェア検索
67
- */
68
- MemberService.prototype.searchSoftwareApplications = function (params) {
69
- return __awaiter(this, void 0, void 0, function () {
70
- var _a, auth, endpoint, project, seller, chevreAdmin, memberService;
71
- return __generator(this, function (_b) {
72
- switch (_b.label) {
73
- case 0:
74
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller;
75
- return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
76
- case 1:
77
- chevreAdmin = _b.sent();
78
- return [4 /*yield*/, chevreAdmin.createMemberInstance({
79
- project: project,
80
- seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
81
- })];
82
- case 2:
83
- memberService = _b.sent();
84
- return [2 /*return*/, memberService.searchSoftwareApplications(params)];
85
- }
86
- });
87
- });
88
- };
89
- return MemberService;
90
- }(service_1.Service));
91
- exports.MemberService = MemberService;