connectbase-client 3.46.0 → 3.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  GameRoom: () => GameRoom,
34
34
  GameRoomTransport: () => GameRoomTransport,
35
35
  NativeAPI: () => NativeAPI,
36
+ RolesAPI: () => RolesAPI,
36
37
  SessionManager: () => SessionManager,
37
38
  VideoProcessingError: () => VideoProcessingError,
38
39
  default: () => index_default,
@@ -5448,6 +5449,38 @@ var PaymentAPI = class {
5448
5449
  const prefix = this.getPublicPrefix();
5449
5450
  return this.http.get(`${prefix}/payments/orders/${orderId}`);
5450
5451
  }
5452
+ /**
5453
+ * 앱의 결제 내역 목록을 조회한다 (필터/페이지네이션 지원).
5454
+ *
5455
+ * 서버사이드 전용 — service_role(ctx.cbAdmin, management_scopes=["payment:read"]) 또는 콘솔 JWT
5456
+ * 인증이 필요하다. 재무 데이터이므로 Public Key(cb_pk_) 단독 브라우저 SDK 인스턴스로는 호출할 수
5457
+ * 없다. (다른 payment 메서드와 달리 /v1/public 이 아니라 앱 스코프 dual-auth 라우트를 쓴다.)
5458
+ *
5459
+ * @example
5460
+ * ```typescript
5461
+ * // 함수(service_role, management_scopes: ["payment:read"]) 안에서
5462
+ * const { payments, total } = await ctx.cbAdmin.payment.list(ctx.appId, { status: 'done', limit: 20 })
5463
+ * ```
5464
+ */
5465
+ async list(appId, options) {
5466
+ if (this.http.hasPublicKey() && !this.http.hasJWT()) {
5467
+ throw new Error(
5468
+ 'cb.payment.list() \uB294 \uCF58\uC194 JWT \uB610\uB294 service_role(ctx.cbAdmin, management_scopes: ["payment:read"]) \uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. Public Key(cb_pk_) \uB2E8\uB3C5 SDK \uC778\uC2A4\uD134\uC2A4\uB85C\uB294 \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 Functions \uD658\uACBD\uC5D0\uC11C \uC0AC\uC6A9\uD558\uC138\uC694.'
5469
+ );
5470
+ }
5471
+ const params = new URLSearchParams();
5472
+ if (options?.status) params.set("status", options.status);
5473
+ if (options?.startDate) params.set("start_date", options.startDate);
5474
+ if (options?.endDate) params.set("end_date", options.endDate);
5475
+ if (options?.limit !== void 0)
5476
+ params.set("limit", String(options.limit));
5477
+ if (options?.offset !== void 0)
5478
+ params.set("offset", String(options.offset));
5479
+ const qs = params.toString();
5480
+ return this.http.get(
5481
+ `/v1/apps/${appId}/payments${qs ? `?${qs}` : ""}`
5482
+ );
5483
+ }
5451
5484
  };
5452
5485
 
5453
5486
  // src/api/subscription.ts
@@ -6049,6 +6082,28 @@ var PushAPI = class {
6049
6082
  };
6050
6083
  return this.http.post(`/v1/apps/${appId}/push/send-to-topic`, body);
6051
6084
  }
6085
+ /**
6086
+ * 앱의 푸시 통계(도달/오픈율/클릭율, 디바이스/메시지/토픽 수)를 조회한다.
6087
+ *
6088
+ * 서버사이드 전용 — service_role(ctx.cbAdmin, management_scopes=["push:read"]) 또는 콘솔 JWT
6089
+ * 인증이 필요하다. sendToMembers/sendToTopic 과 동일한 위임 가드 — cb_pk_ 단독(브라우저) SDK
6090
+ * 인스턴스는 차단하고, 위임 Bearer(ctx.cbAdmin) 인스턴스는 허용한다.
6091
+ *
6092
+ * @example
6093
+ * ```typescript
6094
+ * // 함수(service_role, management_scopes: ["push:read"]) 안에서
6095
+ * const stats = await ctx.cbAdmin.push.getStats(ctx.appId)
6096
+ * console.log(stats.open_rate, stats.click_rate)
6097
+ * ```
6098
+ */
6099
+ async getStats(appId) {
6100
+ if (this.http.hasPublicKey() && !this.http.hasJWT()) {
6101
+ throw new Error(
6102
+ 'cb.push.getStats() \uB294 \uCF58\uC194 JWT \uB610\uB294 service_role(ctx.cbAdmin, management_scopes: ["push:read"]) \uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. Public Key(cb_pk_) \uB2E8\uB3C5 SDK \uC778\uC2A4\uD134\uC2A4\uB85C\uB294 \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 Functions \uD658\uACBD\uC5D0\uC11C \uC0AC\uC6A9\uD558\uC138\uC694.'
6103
+ );
6104
+ }
6105
+ return this.http.get(`/v1/apps/${appId}/push/stats`);
6106
+ }
6052
6107
  // ============ Helper Methods ============
6053
6108
  /**
6054
6109
  * 브라우저 고유 ID 생성 (localStorage에 저장)
@@ -6109,6 +6164,72 @@ var PushAPI = class {
6109
6164
  }
6110
6165
  };
6111
6166
 
6167
+ // src/api/roles.ts
6168
+ var RolesAPI = class {
6169
+ constructor(http) {
6170
+ this.http = http;
6171
+ }
6172
+ ensureServerAuth(method) {
6173
+ if (this.http.hasPublicKey() && !this.http.hasJWT()) {
6174
+ throw new Error(
6175
+ `cb.roles.${method}() \uB294 \uCF58\uC194 JWT \uB610\uB294 service_role(ctx.cbAdmin, management_scopes: ["role:read" | "role:manage"]) \uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. Public Key(cb_pk_) \uB2E8\uB3C5 SDK \uC778\uC2A4\uD134\uC2A4\uB85C\uB294 \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 Functions \uD658\uACBD\uC5D0\uC11C \uC0AC\uC6A9\uD558\uC138\uC694.`
6176
+ );
6177
+ }
6178
+ }
6179
+ /** 앱의 역할 목록을 조회한다. (management_scope: `role:read`) */
6180
+ async list(appId) {
6181
+ this.ensureServerAuth("list");
6182
+ return this.http.get(`/v1/apps/${appId}/app-roles`);
6183
+ }
6184
+ /** 역할 상세(권한/할당 사용자 포함)를 조회한다. (management_scope: `role:read`) */
6185
+ async get(appId, roleId) {
6186
+ this.ensureServerAuth("get");
6187
+ return this.http.get(`/v1/apps/${appId}/app-roles/${roleId}`);
6188
+ }
6189
+ /** 역할을 생성한다. (management_scope: `role:manage`) */
6190
+ async create(appId, payload) {
6191
+ this.ensureServerAuth("create");
6192
+ return this.http.post(`/v1/apps/${appId}/app-roles`, {
6193
+ role_title: payload.title,
6194
+ role_description: payload.description,
6195
+ selected_permission_ids: payload.permissionIds ?? []
6196
+ });
6197
+ }
6198
+ /**
6199
+ * 역할을 수정한다 — **전체 동기화(replace)**. permissionIds / userIds 는 전달값으로 대체된다.
6200
+ * (management_scope: `role:manage`)
6201
+ */
6202
+ async update(appId, roleId, payload) {
6203
+ this.ensureServerAuth("update");
6204
+ await this.http.put(`/v1/apps/${appId}/app-roles/${roleId}`, {
6205
+ role_title: payload.title,
6206
+ role_description: payload.description,
6207
+ selected_permission_ids: payload.permissionIds,
6208
+ selected_user_ids: payload.userIds
6209
+ });
6210
+ }
6211
+ /**
6212
+ * 역할에 사용자를 할당한다 (제목/설명/권한 보존). EditRole 이 전체 동기화라, 현재 상세를 읽어
6213
+ * 나머지 필드를 유지한 채 사용자 목록만 교체해 PUT 한다. userIds 는 "이 역할을 가질 사용자
6214
+ * 전체"다 (추가가 아니라 동기화). (management_scope: `role:manage`)
6215
+ */
6216
+ async assign(appId, roleId, userIds) {
6217
+ this.ensureServerAuth("assign");
6218
+ const detail = await this.http.get(`/v1/apps/${appId}/app-roles/${roleId}`);
6219
+ await this.http.put(`/v1/apps/${appId}/app-roles/${roleId}`, {
6220
+ role_title: detail.role_name,
6221
+ role_description: detail.role_description,
6222
+ selected_permission_ids: detail.permission_item.map((p) => p.id),
6223
+ selected_user_ids: userIds
6224
+ });
6225
+ }
6226
+ /** 역할을 삭제한다. (management_scope: `role:manage`) */
6227
+ async delete(appId, roleId) {
6228
+ this.ensureServerAuth("delete");
6229
+ await this.http.delete(`/v1/apps/${appId}/app-roles/${roleId}`);
6230
+ }
6231
+ };
6232
+
6112
6233
  // src/api/video.ts
6113
6234
  var DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024;
6114
6235
  var VideoProcessingError = class extends Error {
@@ -11197,6 +11318,7 @@ var ConnectBase = class {
11197
11318
  this.payment = new PaymentAPI(this.http);
11198
11319
  this.subscription = new SubscriptionAPI(this.http);
11199
11320
  this.push = new PushAPI(this.http);
11321
+ this.roles = new RolesAPI(this.http);
11200
11322
  this.video = new VideoAPI(this.http, config.videoUrl || env("CB_VIDEO_URL") || DEFAULT_VIDEO_URL);
11201
11323
  this.game = new GameAPI(this.http, config.gameUrl || env("CB_GAME_URL") || DEFAULT_GAME_URL, config.appId);
11202
11324
  this.ads = new AdsAPI(this.http);
@@ -11292,6 +11414,7 @@ var index_default = ConnectBase;
11292
11414
  GameRoom,
11293
11415
  GameRoomTransport,
11294
11416
  NativeAPI,
11417
+ RolesAPI,
11295
11418
  SessionManager,
11296
11419
  VideoProcessingError,
11297
11420
  detectInAppBrowser,
package/dist/index.mjs CHANGED
@@ -5403,6 +5403,38 @@ var PaymentAPI = class {
5403
5403
  const prefix = this.getPublicPrefix();
5404
5404
  return this.http.get(`${prefix}/payments/orders/${orderId}`);
5405
5405
  }
5406
+ /**
5407
+ * 앱의 결제 내역 목록을 조회한다 (필터/페이지네이션 지원).
5408
+ *
5409
+ * 서버사이드 전용 — service_role(ctx.cbAdmin, management_scopes=["payment:read"]) 또는 콘솔 JWT
5410
+ * 인증이 필요하다. 재무 데이터이므로 Public Key(cb_pk_) 단독 브라우저 SDK 인스턴스로는 호출할 수
5411
+ * 없다. (다른 payment 메서드와 달리 /v1/public 이 아니라 앱 스코프 dual-auth 라우트를 쓴다.)
5412
+ *
5413
+ * @example
5414
+ * ```typescript
5415
+ * // 함수(service_role, management_scopes: ["payment:read"]) 안에서
5416
+ * const { payments, total } = await ctx.cbAdmin.payment.list(ctx.appId, { status: 'done', limit: 20 })
5417
+ * ```
5418
+ */
5419
+ async list(appId, options) {
5420
+ if (this.http.hasPublicKey() && !this.http.hasJWT()) {
5421
+ throw new Error(
5422
+ 'cb.payment.list() \uB294 \uCF58\uC194 JWT \uB610\uB294 service_role(ctx.cbAdmin, management_scopes: ["payment:read"]) \uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. Public Key(cb_pk_) \uB2E8\uB3C5 SDK \uC778\uC2A4\uD134\uC2A4\uB85C\uB294 \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 Functions \uD658\uACBD\uC5D0\uC11C \uC0AC\uC6A9\uD558\uC138\uC694.'
5423
+ );
5424
+ }
5425
+ const params = new URLSearchParams();
5426
+ if (options?.status) params.set("status", options.status);
5427
+ if (options?.startDate) params.set("start_date", options.startDate);
5428
+ if (options?.endDate) params.set("end_date", options.endDate);
5429
+ if (options?.limit !== void 0)
5430
+ params.set("limit", String(options.limit));
5431
+ if (options?.offset !== void 0)
5432
+ params.set("offset", String(options.offset));
5433
+ const qs = params.toString();
5434
+ return this.http.get(
5435
+ `/v1/apps/${appId}/payments${qs ? `?${qs}` : ""}`
5436
+ );
5437
+ }
5406
5438
  };
5407
5439
 
5408
5440
  // src/api/subscription.ts
@@ -6004,6 +6036,28 @@ var PushAPI = class {
6004
6036
  };
6005
6037
  return this.http.post(`/v1/apps/${appId}/push/send-to-topic`, body);
6006
6038
  }
6039
+ /**
6040
+ * 앱의 푸시 통계(도달/오픈율/클릭율, 디바이스/메시지/토픽 수)를 조회한다.
6041
+ *
6042
+ * 서버사이드 전용 — service_role(ctx.cbAdmin, management_scopes=["push:read"]) 또는 콘솔 JWT
6043
+ * 인증이 필요하다. sendToMembers/sendToTopic 과 동일한 위임 가드 — cb_pk_ 단독(브라우저) SDK
6044
+ * 인스턴스는 차단하고, 위임 Bearer(ctx.cbAdmin) 인스턴스는 허용한다.
6045
+ *
6046
+ * @example
6047
+ * ```typescript
6048
+ * // 함수(service_role, management_scopes: ["push:read"]) 안에서
6049
+ * const stats = await ctx.cbAdmin.push.getStats(ctx.appId)
6050
+ * console.log(stats.open_rate, stats.click_rate)
6051
+ * ```
6052
+ */
6053
+ async getStats(appId) {
6054
+ if (this.http.hasPublicKey() && !this.http.hasJWT()) {
6055
+ throw new Error(
6056
+ 'cb.push.getStats() \uB294 \uCF58\uC194 JWT \uB610\uB294 service_role(ctx.cbAdmin, management_scopes: ["push:read"]) \uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. Public Key(cb_pk_) \uB2E8\uB3C5 SDK \uC778\uC2A4\uD134\uC2A4\uB85C\uB294 \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 Functions \uD658\uACBD\uC5D0\uC11C \uC0AC\uC6A9\uD558\uC138\uC694.'
6057
+ );
6058
+ }
6059
+ return this.http.get(`/v1/apps/${appId}/push/stats`);
6060
+ }
6007
6061
  // ============ Helper Methods ============
6008
6062
  /**
6009
6063
  * 브라우저 고유 ID 생성 (localStorage에 저장)
@@ -6064,6 +6118,72 @@ var PushAPI = class {
6064
6118
  }
6065
6119
  };
6066
6120
 
6121
+ // src/api/roles.ts
6122
+ var RolesAPI = class {
6123
+ constructor(http) {
6124
+ this.http = http;
6125
+ }
6126
+ ensureServerAuth(method) {
6127
+ if (this.http.hasPublicKey() && !this.http.hasJWT()) {
6128
+ throw new Error(
6129
+ `cb.roles.${method}() \uB294 \uCF58\uC194 JWT \uB610\uB294 service_role(ctx.cbAdmin, management_scopes: ["role:read" | "role:manage"]) \uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. Public Key(cb_pk_) \uB2E8\uB3C5 SDK \uC778\uC2A4\uD134\uC2A4\uB85C\uB294 \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 Functions \uD658\uACBD\uC5D0\uC11C \uC0AC\uC6A9\uD558\uC138\uC694.`
6130
+ );
6131
+ }
6132
+ }
6133
+ /** 앱의 역할 목록을 조회한다. (management_scope: `role:read`) */
6134
+ async list(appId) {
6135
+ this.ensureServerAuth("list");
6136
+ return this.http.get(`/v1/apps/${appId}/app-roles`);
6137
+ }
6138
+ /** 역할 상세(권한/할당 사용자 포함)를 조회한다. (management_scope: `role:read`) */
6139
+ async get(appId, roleId) {
6140
+ this.ensureServerAuth("get");
6141
+ return this.http.get(`/v1/apps/${appId}/app-roles/${roleId}`);
6142
+ }
6143
+ /** 역할을 생성한다. (management_scope: `role:manage`) */
6144
+ async create(appId, payload) {
6145
+ this.ensureServerAuth("create");
6146
+ return this.http.post(`/v1/apps/${appId}/app-roles`, {
6147
+ role_title: payload.title,
6148
+ role_description: payload.description,
6149
+ selected_permission_ids: payload.permissionIds ?? []
6150
+ });
6151
+ }
6152
+ /**
6153
+ * 역할을 수정한다 — **전체 동기화(replace)**. permissionIds / userIds 는 전달값으로 대체된다.
6154
+ * (management_scope: `role:manage`)
6155
+ */
6156
+ async update(appId, roleId, payload) {
6157
+ this.ensureServerAuth("update");
6158
+ await this.http.put(`/v1/apps/${appId}/app-roles/${roleId}`, {
6159
+ role_title: payload.title,
6160
+ role_description: payload.description,
6161
+ selected_permission_ids: payload.permissionIds,
6162
+ selected_user_ids: payload.userIds
6163
+ });
6164
+ }
6165
+ /**
6166
+ * 역할에 사용자를 할당한다 (제목/설명/권한 보존). EditRole 이 전체 동기화라, 현재 상세를 읽어
6167
+ * 나머지 필드를 유지한 채 사용자 목록만 교체해 PUT 한다. userIds 는 "이 역할을 가질 사용자
6168
+ * 전체"다 (추가가 아니라 동기화). (management_scope: `role:manage`)
6169
+ */
6170
+ async assign(appId, roleId, userIds) {
6171
+ this.ensureServerAuth("assign");
6172
+ const detail = await this.http.get(`/v1/apps/${appId}/app-roles/${roleId}`);
6173
+ await this.http.put(`/v1/apps/${appId}/app-roles/${roleId}`, {
6174
+ role_title: detail.role_name,
6175
+ role_description: detail.role_description,
6176
+ selected_permission_ids: detail.permission_item.map((p) => p.id),
6177
+ selected_user_ids: userIds
6178
+ });
6179
+ }
6180
+ /** 역할을 삭제한다. (management_scope: `role:manage`) */
6181
+ async delete(appId, roleId) {
6182
+ this.ensureServerAuth("delete");
6183
+ await this.http.delete(`/v1/apps/${appId}/app-roles/${roleId}`);
6184
+ }
6185
+ };
6186
+
6067
6187
  // src/api/video.ts
6068
6188
  var DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024;
6069
6189
  var VideoProcessingError = class extends Error {
@@ -11152,6 +11272,7 @@ var ConnectBase = class {
11152
11272
  this.payment = new PaymentAPI(this.http);
11153
11273
  this.subscription = new SubscriptionAPI(this.http);
11154
11274
  this.push = new PushAPI(this.http);
11275
+ this.roles = new RolesAPI(this.http);
11155
11276
  this.video = new VideoAPI(this.http, config.videoUrl || env("CB_VIDEO_URL") || DEFAULT_VIDEO_URL);
11156
11277
  this.game = new GameAPI(this.http, config.gameUrl || env("CB_GAME_URL") || DEFAULT_GAME_URL, config.appId);
11157
11278
  this.ads = new AdsAPI(this.http);
@@ -11246,6 +11367,7 @@ export {
11246
11367
  GameRoom,
11247
11368
  GameRoomTransport,
11248
11369
  NativeAPI,
11370
+ RolesAPI,
11249
11371
  SessionManager,
11250
11372
  VideoProcessingError,
11251
11373
  index_default as default,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "3.46.0",
3
+ "version": "3.47.0",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",