@granular-software/sdk 0.4.60 → 0.4.62

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
@@ -12273,6 +12273,7 @@ var StateTransitionInputBindingSchema = external_exports.lazy(
12273
12273
  );
12274
12274
  var StateTransitionActionSchema = external_exports.object({
12275
12275
  effect: external_exports.string().min(1),
12276
+ providerLabel: external_exports.string().optional(),
12276
12277
  input: external_exports.record(external_exports.string(), StateTransitionInputBindingSchema).optional()
12277
12278
  }).strict();
12278
12279
  var StateTransitionAssigneeSchema = external_exports.object({
@@ -14760,6 +14761,15 @@ var stateMachineMetamodelPackage = defineMetamodelPackage({
14760
14761
  is_final: Boolean!
14761
14762
  history: [StateMachineTransitionEvent!]!
14762
14763
  instances_in_state(state: String!): [Model!]!
14764
+ instance_population(state: String!, page: Int = 1, per_page: Int = 50): StateMachineInstancePopulation!
14765
+ }
14766
+
14767
+ type StateMachineInstancePopulation {
14768
+ count: Int!
14769
+ instances: [Model!]!
14770
+ page: Int!
14771
+ per_page: Int!
14772
+ has_more: Boolean!
14763
14773
  }
14764
14774
 
14765
14775
  type StateMachineState {
@@ -14968,6 +14978,13 @@ var stateMachineMetamodelPackage = defineMetamodelPackage({
14968
14978
  value.model.target || value.model,
14969
14979
  value.name,
14970
14980
  state
14981
+ ),
14982
+ instance_population: async (value, { state, page, per_page }) => await stateMachines.instancePopulation(
14983
+ value.model.target || value.model,
14984
+ value.name,
14985
+ state,
14986
+ page,
14987
+ per_page
14971
14988
  )
14972
14989
  }
14973
14990
  };
@@ -18002,11 +18019,16 @@ var Granular = class _Granular {
18002
18019
  `${methodName}() requires at least one permission so the SDK can ensure assignments for new users.`
18003
18020
  );
18004
18021
  }
18005
- for (const profileName of user.permissions) {
18006
- const profileId = await this.ensurePermissionProfile(
18007
- sandbox.sandboxId,
18008
- profileName
18022
+ const permissionProfileIds = [];
18023
+ for (const profileReference of user.permissions) {
18024
+ permissionProfileIds.push(
18025
+ await this.ensurePermissionProfile(
18026
+ sandbox.sandboxId,
18027
+ profileReference
18028
+ )
18009
18029
  );
18030
+ }
18031
+ for (const profileId of permissionProfileIds) {
18010
18032
  await this.ensureAssignment(
18011
18033
  user.granularId,
18012
18034
  sandbox.sandboxId,
@@ -19011,25 +19033,37 @@ var Granular = class _Granular {
19011
19033
  }
19012
19034
  }
19013
19035
  /**
19014
- * Ensure a permission profile exists for a sandbox, creating it if needed.
19015
- * If profileName matches an existing profile name, returns its ID.
19016
- * Otherwise, creates a v1 source-profile file shape with an allow default.
19036
+ * Resolve an existing permission profile by exact name or ID.
19037
+ *
19038
+ * `allow-all` is the sole compatibility profile that the SDK may provision
19039
+ * automatically. Every other missing reference fails closed so a typo or
19040
+ * untrusted role value cannot become an allow-default profile.
19017
19041
  */
19018
- async ensurePermissionProfile(sandboxId, profileName) {
19019
- try {
19020
- const profiles = await this.permissionProfiles.list(sandboxId);
19021
- const existing = profiles.find((p) => p.name === profileName);
19022
- if (existing) {
19023
- return existing.permissionProfileId;
19024
- }
19025
- } catch {
19042
+ async ensurePermissionProfile(sandboxId, profileReference) {
19043
+ const normalizedReference = typeof profileReference === "string" ? profileReference.trim() : "";
19044
+ if (!normalizedReference) {
19045
+ throw new Error(
19046
+ "Permission profile references must be non-empty names or IDs."
19047
+ );
19048
+ }
19049
+ const profiles = await this.permissionProfiles.list(sandboxId);
19050
+ const existing = profiles.find(
19051
+ (profile) => profile.name === normalizedReference || profile.permissionProfileId === normalizedReference
19052
+ );
19053
+ if (existing) {
19054
+ return existing.permissionProfileId;
19055
+ }
19056
+ if (normalizedReference !== "allow-all") {
19057
+ throw new Error(
19058
+ `Permission profile "${normalizedReference}" was not found in sandbox ${sandboxId}. Provision it with granular build or granular deploy before calling openEnvironment(). Only the reserved "allow-all" profile can be created automatically.`
19059
+ );
19026
19060
  }
19027
19061
  const created = await this.permissionProfiles.create(sandboxId, {
19028
- name: profileName,
19062
+ name: normalizedReference,
19029
19063
  rules: {
19030
19064
  schemaVersion: 1,
19031
- name: profileName,
19032
- description: profileName === "allow-all" ? "Every declared action is visible unless a manifest policy denies it." : `Generated permission profile ${profileName}`,
19065
+ name: normalizedReference,
19066
+ description: "Every declared action is visible unless a manifest policy denies it.",
19033
19067
  defaults: { actionPolicy: "allow" },
19034
19068
  actions: []
19035
19069
  }