@snaptrude/plugin-core 0.2.4 → 0.2.6

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/core/geom/arc.d.ts +81 -0
  3. package/dist/api/core/geom/arc.d.ts.map +1 -0
  4. package/dist/api/core/geom/curve.d.ts +70 -0
  5. package/dist/api/core/geom/curve.d.ts.map +1 -0
  6. package/dist/api/core/geom/index.d.ts +32 -0
  7. package/dist/api/core/geom/index.d.ts.map +1 -0
  8. package/dist/api/core/geom/line.d.ts +56 -0
  9. package/dist/api/core/geom/line.d.ts.map +1 -0
  10. package/dist/api/core/geom/profile.d.ts +121 -0
  11. package/dist/api/core/geom/profile.d.ts.map +1 -0
  12. package/dist/api/core/index.d.ts +18 -0
  13. package/dist/api/core/index.d.ts.map +1 -0
  14. package/dist/api/core/math/index.d.ts +18 -0
  15. package/dist/api/core/math/index.d.ts.map +1 -0
  16. package/dist/api/core/math/quat.d.ts +187 -0
  17. package/dist/api/core/math/quat.d.ts.map +1 -0
  18. package/dist/api/core/math/vec3.d.ts +156 -0
  19. package/dist/api/core/math/vec3.d.ts.map +1 -0
  20. package/dist/api/entity/buildableEnvelope.d.ts +233 -0
  21. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  22. package/dist/api/entity/department.d.ts +99 -0
  23. package/dist/api/entity/department.d.ts.map +1 -0
  24. package/dist/api/entity/index.d.ts +33 -0
  25. package/dist/api/entity/index.d.ts.map +1 -0
  26. package/dist/api/entity/referenceLine.d.ts +259 -0
  27. package/dist/api/entity/referenceLine.d.ts.map +1 -0
  28. package/dist/api/entity/space.d.ts +1490 -0
  29. package/dist/api/entity/space.d.ts.map +1 -0
  30. package/dist/api/entity/story.d.ts +239 -0
  31. package/dist/api/entity/story.d.ts.map +1 -0
  32. package/dist/api/index.d.ts +30 -0
  33. package/dist/api/index.d.ts.map +1 -0
  34. package/dist/api/tools/copy.d.ts +59 -0
  35. package/dist/api/tools/copy.d.ts.map +1 -0
  36. package/dist/api/tools/index.d.ts +29 -0
  37. package/dist/api/tools/index.d.ts.map +1 -0
  38. package/dist/api/tools/offset.d.ts +43 -0
  39. package/dist/api/tools/offset.d.ts.map +1 -0
  40. package/dist/api/tools/selection.d.ts +48 -0
  41. package/dist/api/tools/selection.d.ts.map +1 -0
  42. package/dist/api/tools/transform.d.ts +114 -0
  43. package/dist/api/tools/transform.d.ts.map +1 -0
  44. package/dist/api/units/index.d.ts +163 -0
  45. package/dist/api/units/index.d.ts.map +1 -0
  46. package/dist/host-utils.d.ts +41 -0
  47. package/dist/host-utils.d.ts.map +1 -0
  48. package/dist/index.cjs +71 -0
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +63 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/types.d.ts +16 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/package.json +1 -1
  57. package/src/api/entity/space.ts +270 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A unique identifier for a component in the Snaptrude scene.
3
+ *
4
+ * Component IDs are returned by entity creation methods (e.g.
5
+ * {@linkcode PluginSpaceApi.createRectangular}) and can be used with
6
+ * query and transform methods throughout the API.
7
+ */
8
+ export type ComponentId = string;
9
+ /**
10
+ * Return type for a plugin API method.
11
+ *
12
+ * Methods that require a host round-trip return `Promise<T>`,
13
+ * while pure local computations may return `T` directly.
14
+ */
15
+ export type PluginApiReturn<T> = Promise<T> | T;
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-core",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -266,6 +266,112 @@ export abstract class PluginSpaceApi {
266
266
  public abstract update(
267
267
  args: PluginSpaceUpdateArgs,
268
268
  ): PluginApiReturn<PluginSpaceUpdateResult>
269
+
270
+ /**
271
+ * Create many spaces in a single undoable operation.
272
+ *
273
+ * Each item is either a rectangular box (`kind: "rectangular"`) or an
274
+ * extruded profile (`kind: "profile"`), and may optionally set `room_type`,
275
+ * `spaceType`, `massType`, and `departmentId`. All creations — and the
276
+ * optional property assignments — are batched into **one** command, so the
277
+ * entire batch is undone/redone in a single step.
278
+ *
279
+ * All items are validated first; if any item is invalid the call **throws**
280
+ * and no spaces are created (nothing is applied) — consistent with the
281
+ * single-item create methods.
282
+ *
283
+ * @param args - {@linkcode PluginSpaceBulkCreateArgs} with an `items` array
284
+ * @returns A {@linkcode PluginSpaceBulkCreateResult} with the `spaceIds` of
285
+ * the created spaces, in input order
286
+ * @throws If any item has invalid dimensions, height, or profile
287
+ *
288
+ * # Example
289
+ * ```ts
290
+ * const { vec3 } = snaptrude.core.math
291
+ *
292
+ * const { spaceIds } = await snaptrude.entity.space.bulkCreate({
293
+ * items: [
294
+ * {
295
+ * kind: "rectangular",
296
+ * position: vec3.new(0, 0, 0),
297
+ * dimensions: { width: 5, height: 3, depth: 4 },
298
+ * spaceType: "Room",
299
+ * departmentId: "CORE",
300
+ * },
301
+ * {
302
+ * kind: "profile",
303
+ * profile: await snaptrude.core.geom.profile.fromLinePoints({
304
+ * points: [vec3.new(0, 0, 0), vec3.new(8, 0, 0), vec3.new(8, 0, 6), vec3.new(0, 0, 6)],
305
+ * }),
306
+ * extrudeHeight: 3,
307
+ * position: vec3.new(10, 0, 0),
308
+ * massType: "Room",
309
+ * },
310
+ * ],
311
+ * })
312
+ * ```
313
+ */
314
+ public abstract bulkCreate(
315
+ args: PluginSpaceBulkCreateArgs,
316
+ ): PluginApiReturn<PluginSpaceBulkCreateResult>
317
+
318
+ /**
319
+ * Update many existing spaces in a single undoable operation.
320
+ *
321
+ * Each item targets an existing space by `spaceId` and may change its
322
+ * geometry (`profile` + `extrudeHeight`, which must be supplied together) and/or
323
+ * its `properties` (`room_type`, `massType`, `spaceType`, `departmentId` —
324
+ * nested under `properties`, mirroring {@linkcode PluginSpaceApi.update}). All
325
+ * changes are batched into **one** command, so the entire batch is
326
+ * undone/redone in a single step.
327
+ *
328
+ * All items are validated first; if any item is invalid — an unknown
329
+ * `spaceId`, a non-positive height, or supplying only one of
330
+ * `profile`/`extrudeHeight` — the call **throws** and no changes are applied.
331
+ *
332
+ * @param args - {@linkcode PluginSpaceBulkUpdateArgs} with an `items` array
333
+ * @returns A {@linkcode PluginSpaceBulkUpdateResult} echoing one
334
+ * {@linkcode PluginSpaceUpdateResult} per item in `spaces`, in input order
335
+ * @throws If any item targets an unknown space, has a non-positive height, or
336
+ * supplies only one of `profile`/`extrudeHeight`
337
+ *
338
+ * # Example
339
+ * ```ts
340
+ * const { spaces } = await snaptrude.entity.space.bulkUpdate({
341
+ * items: [
342
+ * { spaceId: "space-a", properties: { room_type: "Kitchen", spaceType: "Room" } },
343
+ * { spaceId: "space-b", profile, extrudeHeight: 4 },
344
+ * ],
345
+ * })
346
+ * ```
347
+ */
348
+ public abstract bulkUpdate(
349
+ args: PluginSpaceBulkUpdateArgs,
350
+ ): PluginApiReturn<PluginSpaceBulkUpdateResult>
351
+
352
+ /**
353
+ * Delete many spaces in a single undoable operation.
354
+ *
355
+ * All deletions are batched into **one** command, so the entire batch is
356
+ * undone/redone in a single step.
357
+ *
358
+ * All IDs are validated first; if any ID is unknown or is not a space the
359
+ * call **throws** and no spaces are deleted — consistent with the single-item
360
+ * {@linkcode PluginSpaceApi.delete}.
361
+ *
362
+ * @param args - {@linkcode PluginSpaceBulkDeleteArgs} with a `spaceIds` array
363
+ * @returns A {@linkcode PluginSpaceBulkDeleteResult} with `deletedSpaceIds`
364
+ * (the removed IDs, in input order)
365
+ * @throws If any ID does not resolve to an existing space
366
+ *
367
+ * # Example
368
+ * ```ts
369
+ * await snaptrude.entity.space.bulkDelete({ spaceIds: ["space-a", "space-b"] })
370
+ * ```
371
+ */
372
+ public abstract bulkDelete(
373
+ args: PluginSpaceBulkDeleteArgs,
374
+ ): PluginApiReturn<PluginSpaceBulkDeleteResult>
269
375
  }
270
376
 
271
377
  /**
@@ -659,3 +765,167 @@ export const PluginSpaceUpdateResult = z.object({
659
765
  })
660
766
 
661
767
  export type PluginSpaceUpdateResult = z.infer<typeof PluginSpaceUpdateResult>
768
+
769
+ // ---------------------------------------------------------------------------
770
+ // Bulk operations
771
+ // ---------------------------------------------------------------------------
772
+
773
+ /**
774
+ * A single item for {@linkcode PluginSpaceApi.bulkCreate}.
775
+ *
776
+ * Discriminated on `kind`:
777
+ * - `"rectangular"` — a box defined by `position` + `dimensions` (mirrors
778
+ * {@linkcode PluginSpaceCreateRectangularArgs})
779
+ * - `"profile"` — an extruded `profile` (with optional `innerProfiles`) by
780
+ * `extrudeHeight` at `position` (mirrors {@linkcode PluginSpaceCreateFromProfileArgs})
781
+ *
782
+ * Every item may optionally set `room_type`, `spaceType`, `massType`, and
783
+ * `departmentId`; these are applied within the same single undo step as the
784
+ * creation.
785
+ */
786
+ export const PluginSpaceBulkCreateItem = z.discriminatedUnion("kind", [
787
+ z.object({
788
+ kind: z.literal("rectangular"),
789
+ position: PVec3,
790
+ dimensions: z.object({
791
+ width: z.number(),
792
+ height: z.number(),
793
+ depth: z.number(),
794
+ }),
795
+ room_type: z.string().optional(),
796
+ spaceType: PluginSpaceType.optional(),
797
+ massType: PluginMassType.optional(),
798
+ departmentId: PluginDepartmentId.optional(),
799
+ }),
800
+ z.object({
801
+ kind: z.literal("profile"),
802
+ profile: PProfile,
803
+ innerProfiles: z.array(PProfile).optional(),
804
+ extrudeHeight: z.number(),
805
+ position: PVec3,
806
+ room_type: z.string().optional(),
807
+ spaceType: PluginSpaceType.optional(),
808
+ massType: PluginMassType.optional(),
809
+ departmentId: PluginDepartmentId.optional(),
810
+ }),
811
+ ])
812
+
813
+ export type PluginSpaceBulkCreateItem = z.infer<typeof PluginSpaceBulkCreateItem>
814
+
815
+ /**
816
+ * Arguments for {@linkcode PluginSpaceApi.bulkCreate}.
817
+ *
818
+ * | Property | Type | Description |
819
+ * |---|---|---|
820
+ * | `items` | {@linkcode PluginSpaceBulkCreateItem}`[]` | Spaces to create |
821
+ */
822
+ export const PluginSpaceBulkCreateArgs = z.object({
823
+ items: z.array(PluginSpaceBulkCreateItem),
824
+ })
825
+
826
+ export type PluginSpaceBulkCreateArgs = z.infer<typeof PluginSpaceBulkCreateArgs>
827
+
828
+ /**
829
+ * Result of {@linkcode PluginSpaceApi.bulkCreate}.
830
+ *
831
+ * | Property | Type | Description |
832
+ * |---|---|---|
833
+ * | `spaceIds` | `string[]` | IDs of the created spaces, in input order |
834
+ */
835
+ export const PluginSpaceBulkCreateResult = z.object({
836
+ spaceIds: z.array(z.string()),
837
+ })
838
+
839
+ export type PluginSpaceBulkCreateResult = z.infer<
840
+ typeof PluginSpaceBulkCreateResult
841
+ >
842
+
843
+ /**
844
+ * A single item for {@linkcode PluginSpaceApi.bulkUpdate}.
845
+ *
846
+ * Targets an existing space by `spaceId`. Geometry fields `profile` and
847
+ * `extrudeHeight` must be supplied **together** (mirrors
848
+ * {@linkcode PluginSpaceUpdateGeometryFromProfileArgs}). Property changes are
849
+ * nested under `properties`, mirroring {@linkcode PluginSpaceUpdateArgs}.
850
+ *
851
+ * | Property | Type | Description |
852
+ * |---|---|---|
853
+ * | `spaceId` | `string` | The space to update |
854
+ * | `profile` | {@linkcode PProfile}`?` | New floor shape (requires `extrudeHeight`) |
855
+ * | `extrudeHeight` | `number?` | New extrusion height (requires `profile`) |
856
+ * | `properties` | `object?` | Property changes (same shape as {@linkcode PluginSpaceUpdateArgs.properties}) |
857
+ */
858
+ export const PluginSpaceBulkUpdateItem = z.object({
859
+ spaceId: z.string(),
860
+ profile: PProfile.optional(),
861
+ extrudeHeight: z.number().optional(),
862
+ properties: z
863
+ .object({
864
+ room_type: z.string().optional(),
865
+ massType: PluginMassType.optional(),
866
+ spaceType: PluginSpaceType.optional(),
867
+ departmentId: PluginDepartmentId.optional(),
868
+ })
869
+ .optional(),
870
+ })
871
+
872
+ export type PluginSpaceBulkUpdateItem = z.infer<typeof PluginSpaceBulkUpdateItem>
873
+
874
+ /**
875
+ * Arguments for {@linkcode PluginSpaceApi.bulkUpdate}.
876
+ *
877
+ * | Property | Type | Description |
878
+ * |---|---|---|
879
+ * | `items` | {@linkcode PluginSpaceBulkUpdateItem}`[]` | Spaces to update |
880
+ */
881
+ export const PluginSpaceBulkUpdateArgs = z.object({
882
+ items: z.array(PluginSpaceBulkUpdateItem),
883
+ })
884
+
885
+ export type PluginSpaceBulkUpdateArgs = z.infer<typeof PluginSpaceBulkUpdateArgs>
886
+
887
+ /**
888
+ * Result of {@linkcode PluginSpaceApi.bulkUpdate}.
889
+ *
890
+ * Echoes one {@linkcode PluginSpaceUpdateResult} per item, in input order —
891
+ * the same per-space shape returned by {@linkcode PluginSpaceApi.update}.
892
+ *
893
+ * | Property | Type | Description |
894
+ * |---|---|---|
895
+ * | `spaces` | {@linkcode PluginSpaceUpdateResult}`[]` | Per-item updated values, in input order |
896
+ */
897
+ export const PluginSpaceBulkUpdateResult = z.object({
898
+ spaces: z.array(PluginSpaceUpdateResult),
899
+ })
900
+
901
+ export type PluginSpaceBulkUpdateResult = z.infer<
902
+ typeof PluginSpaceBulkUpdateResult
903
+ >
904
+
905
+ /**
906
+ * Arguments for {@linkcode PluginSpaceApi.bulkDelete}.
907
+ *
908
+ * | Property | Type | Description |
909
+ * |---|---|---|
910
+ * | `spaceIds` | `string[]` | The space IDs to delete |
911
+ */
912
+ export const PluginSpaceBulkDeleteArgs = z.object({
913
+ spaceIds: z.array(z.string()),
914
+ })
915
+
916
+ export type PluginSpaceBulkDeleteArgs = z.infer<typeof PluginSpaceBulkDeleteArgs>
917
+
918
+ /**
919
+ * Result of {@linkcode PluginSpaceApi.bulkDelete}.
920
+ *
921
+ * | Property | Type | Description |
922
+ * |---|---|---|
923
+ * | `deletedSpaceIds` | `string[]` | The space IDs that were removed |
924
+ */
925
+ export const PluginSpaceBulkDeleteResult = z.object({
926
+ deletedSpaceIds: z.array(z.string()),
927
+ })
928
+
929
+ export type PluginSpaceBulkDeleteResult = z.infer<
930
+ typeof PluginSpaceBulkDeleteResult
931
+ >