@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.mjs CHANGED
@@ -725,6 +725,39 @@ var AiGatewayResource = class extends BaseResource {
725
725
  }
726
726
  };
727
727
 
728
+ // src/resources/api-keys.ts
729
+ var ApiKeysResource = class extends BaseResource {
730
+ /**
731
+ * Provision a new application-scoped API key. The plaintext secret is returned
732
+ * exactly once — store it immediately.
733
+ *
734
+ * @param data - The key name, target application, and optional scopes/expiry.
735
+ * @returns The created key including its one-time plaintext secret.
736
+ */
737
+ async create(data) {
738
+ return this.httpClient.post("/api-keys", data);
739
+ }
740
+ /**
741
+ * List the API keys scoped to an application. Secrets are never returned.
742
+ *
743
+ * @param query - The application whose keys should be listed.
744
+ * @returns A paginated list of API key metadata.
745
+ */
746
+ async list(query) {
747
+ return this.httpClient.get("/api-keys", {
748
+ query
749
+ });
750
+ }
751
+ /**
752
+ * Permanently revoke an API key.
753
+ *
754
+ * @param apiKeyId - The API key ID (UUID).
755
+ */
756
+ async delete(apiKeyId) {
757
+ return this.httpClient.delete(`/api-keys/${apiKeyId}`);
758
+ }
759
+ };
760
+
728
761
  // src/resources/application-env-vars.ts
729
762
  var ApplicationEnvVarsResource = class extends BaseResource {
730
763
  /**
@@ -746,6 +779,27 @@ var ApplicationEnvVarsResource = class extends BaseResource {
746
779
  query
747
780
  });
748
781
  }
782
+ /**
783
+ * Pull the environment variables that apply to an application for local
784
+ * development. Merges organization-wide, application-wide, and (optionally)
785
+ * environment-specific overrides, returning only non-sensitive values — ready
786
+ * to write to a local `.env` file.
787
+ *
788
+ * @param applicationId - The application ID (UUID).
789
+ * @param query - Optional environment targeting.
790
+ * @returns The resolved non-sensitive variables plus the count of omitted secrets.
791
+ *
792
+ * @example
793
+ * ```ts
794
+ * const { items } = await client.applications.envVars.pull('app-id');
795
+ * const dotenv = items.map((v) => `${v.key}=${v.value}`).join('\n');
796
+ * ```
797
+ */
798
+ async pull(applicationId, query) {
799
+ return this.httpClient.get(`/applications/${applicationId}/env-vars/pull`, {
800
+ query
801
+ });
802
+ }
749
803
  /**
750
804
  * Create a new environment variable for an application.
751
805
  *
@@ -1973,6 +2027,83 @@ var OrganizationEnvVarsResource = class extends BaseResource {
1973
2027
  }
1974
2028
  };
1975
2029
 
2030
+ // src/resources/organization-members.ts
2031
+ var OrganizationMembersResource = class extends BaseResource {
2032
+ /**
2033
+ * List the users who belong to an organization.
2034
+ *
2035
+ * @param organizationId - Organization whose members should be listed.
2036
+ * @param query - Optional pagination.
2037
+ * @returns A paginated list of organization members.
2038
+ *
2039
+ * @example
2040
+ * ```ts
2041
+ * const { items, total } = await client.organizations.members.list('org-id');
2042
+ * console.log(`Found ${total} members`);
2043
+ * ```
2044
+ */
2045
+ async list(organizationId, query) {
2046
+ return this.httpClient.get(`/organizations/${organizationId}/members`, {
2047
+ query
2048
+ });
2049
+ }
2050
+ };
2051
+
2052
+ // src/resources/organization-products.ts
2053
+ var OrganizationProductsResource = class extends BaseResource {
2054
+ /**
2055
+ * List effective product access for every organization-scoped product.
2056
+ *
2057
+ * @param organizationId - Organization whose product access should be listed.
2058
+ * @param query - Optional pagination.
2059
+ * @returns A paginated list of product access summaries.
2060
+ *
2061
+ * @example
2062
+ * ```ts
2063
+ * const { items } = await client.organizations.products.list('org-id');
2064
+ * for (const item of items) {
2065
+ * console.log(item.product.slug, item.hasAccess);
2066
+ * }
2067
+ * ```
2068
+ */
2069
+ async list(organizationId, query) {
2070
+ return this.httpClient.get(`/organizations/${organizationId}/products`, {
2071
+ query
2072
+ });
2073
+ }
2074
+ /**
2075
+ * Get effective access for one organization-scoped product.
2076
+ *
2077
+ * @param organizationId - Organization to inspect.
2078
+ * @param product - Product slug from the product registry.
2079
+ * @returns Product access summary including entitlement and subscription state.
2080
+ *
2081
+ * @example
2082
+ * ```ts
2083
+ * const access = await client.organizations.products.get('org-id', 'office');
2084
+ * console.log(access.hasAccess, access.subscription?.plan);
2085
+ * ```
2086
+ */
2087
+ async get(organizationId, product) {
2088
+ return this.httpClient.get(`/organizations/${organizationId}/products/${product}`);
2089
+ }
2090
+ /**
2091
+ * Check whether an organization currently has access to a product.
2092
+ *
2093
+ * @param organizationId - Organization to check.
2094
+ * @param product - Product slug from the product registry.
2095
+ * @returns Compact entitlement check result.
2096
+ *
2097
+ * @example
2098
+ * ```ts
2099
+ * const { hasAccess } = await client.organizations.products.checkEntitlement('org-id', 'network');
2100
+ * ```
2101
+ */
2102
+ async checkEntitlement(organizationId, product) {
2103
+ return this.httpClient.get(`/organizations/${organizationId}/products/${product}/entitlement`);
2104
+ }
2105
+ };
2106
+
1976
2107
  // src/resources/organizations.ts
1977
2108
  var OrganizationsResource = class extends BaseResource {
1978
2109
  /**
@@ -2003,10 +2134,31 @@ var OrganizationsResource = class extends BaseResource {
2003
2134
  * ```
2004
2135
  */
2005
2136
  aiGateway;
2137
+ /**
2138
+ * List organization members and membership roles.
2139
+ *
2140
+ * @example
2141
+ * ```ts
2142
+ * const { items } = await client.organizations.members.list('org-id');
2143
+ * ```
2144
+ */
2145
+ members;
2146
+ /**
2147
+ * Inspect organization product entitlements. Read-only through the public
2148
+ * API — plan changes happen in Gigadrive product surfaces, not via the SDK.
2149
+ *
2150
+ * @example
2151
+ * ```ts
2152
+ * const check = await client.organizations.products.checkEntitlement('org-id', 'office');
2153
+ * ```
2154
+ */
2155
+ products;
2006
2156
  constructor(...args) {
2007
2157
  super(...args);
2008
2158
  this.envVars = new OrganizationEnvVarsResource(this.httpClient);
2009
2159
  this.aiGateway = new OrganizationAiGatewayResource(this.httpClient);
2160
+ this.members = new OrganizationMembersResource(this.httpClient);
2161
+ this.products = new OrganizationProductsResource(this.httpClient);
2010
2162
  }
2011
2163
  /**
2012
2164
  * List organizations the authenticated actor has access to.
@@ -2025,6 +2177,39 @@ var OrganizationsResource = class extends BaseResource {
2025
2177
  query
2026
2178
  });
2027
2179
  }
2180
+ /**
2181
+ * Get a single organization by ID.
2182
+ *
2183
+ * @param organizationId - Organization to retrieve.
2184
+ * @returns The organization.
2185
+ *
2186
+ * @example
2187
+ * ```ts
2188
+ * const org = await client.organizations.get('org-id');
2189
+ * console.log(org.name, org.slug);
2190
+ * ```
2191
+ */
2192
+ async get(organizationId) {
2193
+ return this.httpClient.get(`/organizations/${organizationId}`);
2194
+ }
2195
+ /**
2196
+ * Create a new organization.
2197
+ *
2198
+ * Requires a user-backed token with the `platform:organizations:write` scope.
2199
+ * The authenticated user becomes the organization owner.
2200
+ *
2201
+ * @param input - Organization creation input.
2202
+ * @returns The created organization.
2203
+ *
2204
+ * @example
2205
+ * ```ts
2206
+ * const org = await client.organizations.create({ name: 'Acme Corp' });
2207
+ * console.log(org.id, org.slug);
2208
+ * ```
2209
+ */
2210
+ async create(input) {
2211
+ return this.httpClient.post("/organizations", input);
2212
+ }
2028
2213
  };
2029
2214
 
2030
2215
  // src/client.ts
@@ -2038,6 +2223,8 @@ var GigadriveClient = class {
2038
2223
  deployments;
2039
2224
  /** AI Gateway — OpenAI-compatible chat completions and model listing. */
2040
2225
  aiGateway;
2226
+ /** Application-scoped API key management (create, list, revoke). */
2227
+ apiKeys;
2041
2228
  constructor(config = {}) {
2042
2229
  const baseUrl = config.baseUrl ?? readEnv("GIGADRIVE_API_BASE_URL") ?? DEFAULT_BASE_URL2;
2043
2230
  const fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
@@ -2048,6 +2235,7 @@ var GigadriveClient = class {
2048
2235
  this.applications = new ApplicationsResource(httpClient);
2049
2236
  this.deployments = new DeploymentsResource(httpClient);
2050
2237
  this.aiGateway = new AiGatewayResource(httpClient);
2238
+ this.apiKeys = new ApiKeysResource(httpClient);
2051
2239
  }
2052
2240
  };
2053
2241
 
@@ -2070,6 +2258,7 @@ export {
2070
2258
  AiGatewayUsageResource,
2071
2259
  AiGatewayVideosResource,
2072
2260
  ApiError,
2261
+ ApiKeysResource,
2073
2262
  ApplicationEnvVarsResource,
2074
2263
  ApplicationRequestsResource,
2075
2264
  ApplicationStorageResource,
@@ -2080,6 +2269,8 @@ export {
2080
2269
  GigadriveError,
2081
2270
  OrganizationAiGatewayResource,
2082
2271
  OrganizationEnvVarsResource,
2272
+ OrganizationMembersResource,
2273
+ OrganizationProductsResource,
2083
2274
  OrganizationsResource,
2084
2275
  StorageBucketsResource,
2085
2276
  StorageObjectsResource,