@gigadrive/sdk 0.2.0 → 0.4.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
@@ -37,6 +37,7 @@ __export(src_exports, {
37
37
  AiGatewayUsageResource: () => AiGatewayUsageResource,
38
38
  AiGatewayVideosResource: () => AiGatewayVideosResource,
39
39
  ApiError: () => ApiError,
40
+ ApiKeysResource: () => ApiKeysResource,
40
41
  ApplicationEnvVarsResource: () => ApplicationEnvVarsResource,
41
42
  ApplicationRequestsResource: () => ApplicationRequestsResource,
42
43
  ApplicationStorageResource: () => ApplicationStorageResource,
@@ -47,6 +48,8 @@ __export(src_exports, {
47
48
  GigadriveError: () => GigadriveError,
48
49
  OrganizationAiGatewayResource: () => OrganizationAiGatewayResource,
49
50
  OrganizationEnvVarsResource: () => OrganizationEnvVarsResource,
51
+ OrganizationMembersResource: () => OrganizationMembersResource,
52
+ OrganizationProductsResource: () => OrganizationProductsResource,
50
53
  OrganizationsResource: () => OrganizationsResource,
51
54
  StorageBucketsResource: () => StorageBucketsResource,
52
55
  StorageObjectsResource: () => StorageObjectsResource,
@@ -785,6 +788,39 @@ var AiGatewayResource = class extends BaseResource {
785
788
  }
786
789
  };
787
790
 
791
+ // src/resources/api-keys.ts
792
+ var ApiKeysResource = class extends BaseResource {
793
+ /**
794
+ * Provision a new application-scoped API key. The plaintext secret is returned
795
+ * exactly once — store it immediately.
796
+ *
797
+ * @param data - The key name, target application, and optional scopes/expiry.
798
+ * @returns The created key including its one-time plaintext secret.
799
+ */
800
+ async create(data) {
801
+ return this.httpClient.post("/api-keys", data);
802
+ }
803
+ /**
804
+ * List the API keys scoped to an application. Secrets are never returned.
805
+ *
806
+ * @param query - The application whose keys should be listed.
807
+ * @returns A paginated list of API key metadata.
808
+ */
809
+ async list(query) {
810
+ return this.httpClient.get("/api-keys", {
811
+ query
812
+ });
813
+ }
814
+ /**
815
+ * Permanently revoke an API key.
816
+ *
817
+ * @param apiKeyId - The API key ID (UUID).
818
+ */
819
+ async delete(apiKeyId) {
820
+ return this.httpClient.delete(`/api-keys/${apiKeyId}`);
821
+ }
822
+ };
823
+
788
824
  // src/resources/application-env-vars.ts
789
825
  var ApplicationEnvVarsResource = class extends BaseResource {
790
826
  /**
@@ -806,6 +842,27 @@ var ApplicationEnvVarsResource = class extends BaseResource {
806
842
  query
807
843
  });
808
844
  }
845
+ /**
846
+ * Pull the environment variables that apply to an application for local
847
+ * development. Merges organization-wide, application-wide, and (optionally)
848
+ * environment-specific overrides, returning only non-sensitive values — ready
849
+ * to write to a local `.env` file.
850
+ *
851
+ * @param applicationId - The application ID (UUID).
852
+ * @param query - Optional environment targeting.
853
+ * @returns The resolved non-sensitive variables plus the count of omitted secrets.
854
+ *
855
+ * @example
856
+ * ```ts
857
+ * const { items } = await client.applications.envVars.pull('app-id');
858
+ * const dotenv = items.map((v) => `${v.key}=${v.value}`).join('\n');
859
+ * ```
860
+ */
861
+ async pull(applicationId, query) {
862
+ return this.httpClient.get(`/applications/${applicationId}/env-vars/pull`, {
863
+ query
864
+ });
865
+ }
809
866
  /**
810
867
  * Create a new environment variable for an application.
811
868
  *
@@ -2033,6 +2090,83 @@ var OrganizationEnvVarsResource = class extends BaseResource {
2033
2090
  }
2034
2091
  };
2035
2092
 
2093
+ // src/resources/organization-members.ts
2094
+ var OrganizationMembersResource = class extends BaseResource {
2095
+ /**
2096
+ * List the users who belong to an organization.
2097
+ *
2098
+ * @param organizationId - Organization whose members should be listed.
2099
+ * @param query - Optional pagination.
2100
+ * @returns A paginated list of organization members.
2101
+ *
2102
+ * @example
2103
+ * ```ts
2104
+ * const { items, total } = await client.organizations.members.list('org-id');
2105
+ * console.log(`Found ${total} members`);
2106
+ * ```
2107
+ */
2108
+ async list(organizationId, query) {
2109
+ return this.httpClient.get(`/organizations/${organizationId}/members`, {
2110
+ query
2111
+ });
2112
+ }
2113
+ };
2114
+
2115
+ // src/resources/organization-products.ts
2116
+ var OrganizationProductsResource = class extends BaseResource {
2117
+ /**
2118
+ * List effective product access for every organization-scoped product.
2119
+ *
2120
+ * @param organizationId - Organization whose product access should be listed.
2121
+ * @param query - Optional pagination.
2122
+ * @returns A paginated list of product access summaries.
2123
+ *
2124
+ * @example
2125
+ * ```ts
2126
+ * const { items } = await client.organizations.products.list('org-id');
2127
+ * for (const item of items) {
2128
+ * console.log(item.product.slug, item.hasAccess);
2129
+ * }
2130
+ * ```
2131
+ */
2132
+ async list(organizationId, query) {
2133
+ return this.httpClient.get(`/organizations/${organizationId}/products`, {
2134
+ query
2135
+ });
2136
+ }
2137
+ /**
2138
+ * Get effective access for one organization-scoped product.
2139
+ *
2140
+ * @param organizationId - Organization to inspect.
2141
+ * @param product - Product slug from the product registry.
2142
+ * @returns Product access summary including entitlement and subscription state.
2143
+ *
2144
+ * @example
2145
+ * ```ts
2146
+ * const access = await client.organizations.products.get('org-id', 'office');
2147
+ * console.log(access.hasAccess, access.subscription?.plan);
2148
+ * ```
2149
+ */
2150
+ async get(organizationId, product) {
2151
+ return this.httpClient.get(`/organizations/${organizationId}/products/${product}`);
2152
+ }
2153
+ /**
2154
+ * Check whether an organization currently has access to a product.
2155
+ *
2156
+ * @param organizationId - Organization to check.
2157
+ * @param product - Product slug from the product registry.
2158
+ * @returns Compact entitlement check result.
2159
+ *
2160
+ * @example
2161
+ * ```ts
2162
+ * const { hasAccess } = await client.organizations.products.checkEntitlement('org-id', 'network');
2163
+ * ```
2164
+ */
2165
+ async checkEntitlement(organizationId, product) {
2166
+ return this.httpClient.get(`/organizations/${organizationId}/products/${product}/entitlement`);
2167
+ }
2168
+ };
2169
+
2036
2170
  // src/resources/organizations.ts
2037
2171
  var OrganizationsResource = class extends BaseResource {
2038
2172
  /**
@@ -2063,10 +2197,31 @@ var OrganizationsResource = class extends BaseResource {
2063
2197
  * ```
2064
2198
  */
2065
2199
  aiGateway;
2200
+ /**
2201
+ * List organization members and membership roles.
2202
+ *
2203
+ * @example
2204
+ * ```ts
2205
+ * const { items } = await client.organizations.members.list('org-id');
2206
+ * ```
2207
+ */
2208
+ members;
2209
+ /**
2210
+ * Inspect organization product entitlements. Read-only through the public
2211
+ * API — plan changes happen in Gigadrive product surfaces, not via the SDK.
2212
+ *
2213
+ * @example
2214
+ * ```ts
2215
+ * const check = await client.organizations.products.checkEntitlement('org-id', 'office');
2216
+ * ```
2217
+ */
2218
+ products;
2066
2219
  constructor(...args) {
2067
2220
  super(...args);
2068
2221
  this.envVars = new OrganizationEnvVarsResource(this.httpClient);
2069
2222
  this.aiGateway = new OrganizationAiGatewayResource(this.httpClient);
2223
+ this.members = new OrganizationMembersResource(this.httpClient);
2224
+ this.products = new OrganizationProductsResource(this.httpClient);
2070
2225
  }
2071
2226
  /**
2072
2227
  * List organizations the authenticated actor has access to.
@@ -2085,6 +2240,39 @@ var OrganizationsResource = class extends BaseResource {
2085
2240
  query
2086
2241
  });
2087
2242
  }
2243
+ /**
2244
+ * Get a single organization by ID.
2245
+ *
2246
+ * @param organizationId - Organization to retrieve.
2247
+ * @returns The organization.
2248
+ *
2249
+ * @example
2250
+ * ```ts
2251
+ * const org = await client.organizations.get('org-id');
2252
+ * console.log(org.name, org.slug);
2253
+ * ```
2254
+ */
2255
+ async get(organizationId) {
2256
+ return this.httpClient.get(`/organizations/${organizationId}`);
2257
+ }
2258
+ /**
2259
+ * Create a new organization.
2260
+ *
2261
+ * Requires a user-backed token with the `platform:organizations:write` scope.
2262
+ * The authenticated user becomes the organization owner.
2263
+ *
2264
+ * @param input - Organization creation input.
2265
+ * @returns The created organization.
2266
+ *
2267
+ * @example
2268
+ * ```ts
2269
+ * const org = await client.organizations.create({ name: 'Acme Corp' });
2270
+ * console.log(org.id, org.slug);
2271
+ * ```
2272
+ */
2273
+ async create(input) {
2274
+ return this.httpClient.post("/organizations", input);
2275
+ }
2088
2276
  };
2089
2277
 
2090
2278
  // src/client.ts
@@ -2098,6 +2286,8 @@ var GigadriveClient = class {
2098
2286
  deployments;
2099
2287
  /** AI Gateway — OpenAI-compatible chat completions and model listing. */
2100
2288
  aiGateway;
2289
+ /** Application-scoped API key management (create, list, revoke). */
2290
+ apiKeys;
2101
2291
  constructor(config = {}) {
2102
2292
  const baseUrl = config.baseUrl ?? readEnv("GIGADRIVE_API_BASE_URL") ?? DEFAULT_BASE_URL2;
2103
2293
  const fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
@@ -2108,6 +2298,7 @@ var GigadriveClient = class {
2108
2298
  this.applications = new ApplicationsResource(httpClient);
2109
2299
  this.deployments = new DeploymentsResource(httpClient);
2110
2300
  this.aiGateway = new AiGatewayResource(httpClient);
2301
+ this.apiKeys = new ApiKeysResource(httpClient);
2111
2302
  }
2112
2303
  };
2113
2304
 
@@ -2131,6 +2322,7 @@ async function* paginate(fetchPage) {
2131
2322
  AiGatewayUsageResource,
2132
2323
  AiGatewayVideosResource,
2133
2324
  ApiError,
2325
+ ApiKeysResource,
2134
2326
  ApplicationEnvVarsResource,
2135
2327
  ApplicationRequestsResource,
2136
2328
  ApplicationStorageResource,
@@ -2141,6 +2333,8 @@ async function* paginate(fetchPage) {
2141
2333
  GigadriveError,
2142
2334
  OrganizationAiGatewayResource,
2143
2335
  OrganizationEnvVarsResource,
2336
+ OrganizationMembersResource,
2337
+ OrganizationProductsResource,
2144
2338
  OrganizationsResource,
2145
2339
  StorageBucketsResource,
2146
2340
  StorageObjectsResource,