@draftlab/auth 0.17.0 → 0.18.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.
@@ -82,6 +82,33 @@ export type SubjectPayload<T extends SubjectSchema> = Prettify<{
82
82
  properties: StandardSchemaV1.InferOutput<T[K]>;
83
83
  };
84
84
  }[keyof T & string]>;
85
+ /**
86
+ * Extracts the properties type for a specific subject from a subject schema.
87
+ * Useful for creating type aliases for your application's domain models.
88
+ *
89
+ * @template Schema - The subject schema
90
+ * @template Type - The subject type key to extract properties from
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { createSubjects, InferSubjectProperties } from "@draftlab/auth/subject"
95
+ * import { object, string } from "valibot"
96
+ *
97
+ * const subjects = createSubjects({
98
+ * user: object({
99
+ * userID: string(),
100
+ * email: string()
101
+ * })
102
+ * })
103
+ *
104
+ * // Extract the user properties type
105
+ * type User = InferSubjectProperties<typeof subjects, "user">
106
+ * // Result: { userID: string; email: string }
107
+ * ```
108
+ */
109
+ export type InferSubjectProperties<Schema extends SubjectSchema, Type extends keyof Schema & string> = Extract<SubjectPayload<Schema>, {
110
+ type: Type;
111
+ }>["properties"];
85
112
  /**
86
113
  * Creates a strongly-typed subject schema that can be used throughout your application.
87
114
  * The returned schema maintains type information for excellent IDE support and runtime validation.
@@ -1 +1 @@
1
- {"version":3,"file":"subject.d.ts","sourceRoot":"","sources":["../../src/subject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,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AAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,YAAY,CAAC,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,aAAa,EAAE,OAAO,MAAM,KAAG,MAE5E,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftlab/auth",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "Core implementation for @draftlab/auth",
6
6
  "author": "Matheus Pergoli",